From 5f5bc3935b2760fd06d41102ffe7c19db92bec00 Mon Sep 17 00:00:00 2001 From: Justin Xiao <94207497+jxiao21@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:59:03 -0400 Subject: [PATCH] Add last_accessed_date field (#1610) * changed function call logger.info to logger.debug * model changed, migration file added, may be missing a migration file? since I think it should be 0029 not 0028 * updated migrations to match master * removing deleted file * added last_accessed_date field to admin.py --- dashboard/admin.py | 6 +++--- .../0030_course_last_accessed_date.py | 18 ++++++++++++++++++ dashboard/models.py | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 dashboard/migrations/0030_course_last_accessed_date.py diff --git a/dashboard/admin.py b/dashboard/admin.py index 005706b7..78e6ebea 100644 --- a/dashboard/admin.py +++ b/dashboard/admin.py @@ -82,10 +82,10 @@ def has_add_permission(self, request): class CourseAdmin(admin.ModelAdmin): inlines = [CourseViewOptionInline, ] form = CourseForm - fields = ('canvas_id', 'name', 'term', 'date_start', 'date_end', 'show_grade_counts', 'show_grade_type', 'data_last_updated', 'date_created') - list_display = ('canvas_id', 'name', 'term', 'show_grade_counts', 'course_link', '_courseviewoption', 'data_last_updated', 'date_created') + fields = ('canvas_id', 'name', 'term', 'date_start', 'date_end', 'show_grade_counts', 'show_grade_type', 'data_last_updated', 'date_created', 'last_accessed_date') + list_display = ('canvas_id', 'name', 'term', 'show_grade_counts', 'course_link', '_courseviewoption', 'data_last_updated', 'date_created', 'last_accessed_date') list_select_related = True - readonly_fields = ('term', 'data_last_updated', 'date_created') + readonly_fields = ('term', 'data_last_updated', 'date_created', 'last_accessed_date') actions = ['clear_course_updated_dates'] def view_on_site(self, obj): diff --git a/dashboard/migrations/0030_course_last_accessed_date.py b/dashboard/migrations/0030_course_last_accessed_date.py new file mode 100644 index 00000000..5bd3653f --- /dev/null +++ b/dashboard/migrations/0030_course_last_accessed_date.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.14 on 2024-08-16 15:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dashboard', '0029_resourceaccess_user_id_idx'), + ] + + operations = [ + migrations.AddField( + model_name='course', + name='last_accessed_date', + field=models.DateTimeField(blank=True, help_text='The last time this course was accessed', null=True), + ), + ] diff --git a/dashboard/models.py b/dashboard/models.py index 0fcaa189..e7af808f 100644 --- a/dashboard/models.py +++ b/dashboard/models.py @@ -205,7 +205,7 @@ class Course(models.Model): choices=GRADING_CHOICES, default='Percent') data_last_updated = models.DateTimeField(null=True, blank=True, help_text="This is the last time the cron was run and can be reset on the main courses page with the dropdown") date_created = models.DateTimeField(verbose_name="Date course was created", default=datetime.now, null=True, blank=True) - + last_accessed_date = models.DateTimeField(blank=True, null=True, help_text='The last time this course was accessed') objects = CourseQuerySet().as_manager() def __str__(self):