Skip to content

Commit

Permalink
Fixes #1399 - Add Django Admin function to clear course updated dates. (
Browse files Browse the repository at this point in the history
  • Loading branch information
jonespm committed Sep 2, 2022
1 parent cb389fb commit 2435e43
Show file tree
Hide file tree
Showing 3 changed files with 26 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 last updated values')
def clear_course_updated_dates(self, request, queryset):
queryset.update(data_last_updated=None)
self.message_user(request, "All selected last updated values cleared.")

# Need this method to correctly display the line breaks
def _courseviewoption(self, obj):
Expand Down
18 changes: 18 additions & 0 deletions dashboard/migrations/0023_alter_course_data_last_updated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.15 on 2022-09-02 19:43

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0022_remove_user_sis_id'),
]

operations = [
migrations.AlterField(
model_name='course',
name='data_last_updated',
field=models.DateTimeField(blank=True, null=True, verbose_name='Data last updated'),
),
]
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="Data last updated", null=True, blank=True)

objects = CourseQuerySet().as_manager()

Expand Down

0 comments on commit 2435e43

Please sign in to comment.