diff --git a/dashboard/admin.py b/dashboard/admin.py index db72e7a2..5e0b805b 100644 --- a/dashboard/admin.py +++ b/dashboard/admin.py @@ -79,10 +79,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') - list_display = ('canvas_id', 'name', 'term', 'show_grade_counts', 'course_link', '_courseviewoption', 'data_last_updated') + 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') list_select_related = True - readonly_fields = ('term', 'data_last_updated',) + readonly_fields = ('term', 'data_last_updated', 'date_created') actions = ['clear_course_updated_dates'] def view_on_site(self, obj): diff --git a/dashboard/migrations/0026_course_date_created.py b/dashboard/migrations/0026_course_date_created.py new file mode 100644 index 00000000..07f99242 --- /dev/null +++ b/dashboard/migrations/0026_course_date_created.py @@ -0,0 +1,25 @@ +# Generated by Django 3.2.20 on 2023-09-06 18:48 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dashboard', '0025_remove_courseviewoption_show_assignment_planning_v1'), + ] + + # Initially set this to null but alter it to default to the current date + operations = [ + migrations.AddField( + model_name='course', + name='date_created', + field=models.DateTimeField(default=None, null=True, blank=True, verbose_name='Date course was created'), + ), + migrations.AlterField( + model_name='course', + name='date_created', + field=models.DateTimeField(blank=True, default=datetime.datetime.now, null=True, verbose_name='Date course was created'), + ), + ] diff --git a/dashboard/models.py b/dashboard/models.py index e1996d87..f3061508 100644 --- a/dashboard/models.py +++ b/dashboard/models.py @@ -205,6 +205,7 @@ class Course(models.Model): 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="Data last updated", null=True, blank=True) + date_created = models.DateTimeField(verbose_name="Date course was created", default=datetime.now, null=True, blank=True) objects = CourseQuerySet().as_manager()