Skip to content

Commit

Permalink
Fixes tl-its-umich-edu#1399 - Add Django Admin function to clear cour…
Browse files Browse the repository at this point in the history
…se updated dates.
  • Loading branch information
jonespm committed Aug 26, 2022
1 parent b0d05c1 commit 9847581
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion dashboard/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,15 @@ def has_add_permission(self, request):
class CourseAdmin(admin.ModelAdmin):
inlines = [CourseViewOptionInline, ]
form = CourseForm
list_display = ('canvas_id', 'name', 'term', 'show_grade_counts', 'course_link', '_courseviewoption', 'show_grade_type')
list_display = ('canvas_id', 'name', 'term', 'show_grade_counts', 'course_link', '_courseviewoption', 'data_last_updated')
list_select_related = True
readonly_fields = ('term', 'data_last_updated',)
actions = ['clear_course_updated_dates']

@admin.action(description='Clear selected Courses updated dates')
def clear_course_updated_dates(self, request, queryset):
queryset.update(data_last_updated=None)
self.message_user(request, "All selected course updated dates are cleared.")

# Need this method to correctly display the line breaks
def _courseviewoption(self, obj):
Expand Down
2 changes: 1 addition & 1 deletion dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class Course(models.Model):
GRADING_CHOICES = [('Percent', 'Percent'), ('Point', 'Point'), ]
show_grade_type = models.CharField(verbose_name="Show Grade Type", max_length=255,
choices=GRADING_CHOICES, default='Percent')
data_last_updated = models.DateTimeField(verbose_name="Time data for this course was last updated", null=True, blank=True)
data_last_updated = models.DateTimeField(verbose_name="When this course was last updated", null=True, blank=True)

objects = CourseQuerySet().as_manager()

Expand Down

0 comments on commit 9847581

Please sign in to comment.