Skip to content

Commit

Permalink
Fixes #1501 - Add username to the export (#1538)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonespm authored Sep 13, 2023
1 parent 9cb87ad commit 9018413
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dashboard/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
from rangefilter.filters import DateTimeRangeFilter


from import_export.admin import ExportActionMixin
from import_export import resources
from import_export.admin import ExportActionMixin
from import_export.fields import Field

from dashboard.common.db_util import canvas_id_to_incremented_id
from dashboard.models import AcademicTerms, Course, CourseViewOption
Expand Down Expand Up @@ -115,8 +116,14 @@ def save_model(self, request, obj, form, change):
return super(CourseAdmin, self).save_model(request, obj, form, change)

class LogResource(resources.ModelResource):

# This field is used to get the username from the auth_user model
username = Field(attribute='user__username', column_name='username')
class Meta:
model = Log
# Show the same fields in the UI
fields = ('id', 'timestamp', 'username', 'action', 'extra')
export_order = fields

# This is a local class for LogAdmin that adds in export and disables adding and removing logs
class MyLALogAdmin(ExportActionMixin, LogAdmin):
Expand Down

0 comments on commit 9018413

Please sign in to comment.