From 576e35295c8f8f11a4612861c4288e5885ff37cf Mon Sep 17 00:00:00 2001 From: annagav Date: Thu, 26 Sep 2024 09:15:20 -0400 Subject: [PATCH] Adding dates on Program model (#2404) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- courses/admin.py | 2 +- ...nd_date_program_enrollment_end_and_more.py | 32 +++++++++++++++++++ courses/models.py | 4 +++ courses/serializers/v2/programs.py | 4 +++ courses/serializers/v2/programs_test.py | 4 +++ 5 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 courses/migrations/0056_program_end_date_program_enrollment_end_and_more.py diff --git a/courses/admin.py b/courses/admin.py index 84f3c9cd23..e6c9683ebc 100644 --- a/courses/admin.py +++ b/courses/admin.py @@ -41,7 +41,7 @@ class ProgramAdmin(admin.ModelAdmin): model = Program form = ProgramAdminForm search_fields = ["title", "readable_id", "program_type"] - list_display = ("id", "title", "readable_id", "program_type") + list_display = ("id", "title", "live", "readable_id", "program_type") list_filter = ["live", "program_type", "departments"] diff --git a/courses/migrations/0056_program_end_date_program_enrollment_end_and_more.py b/courses/migrations/0056_program_end_date_program_enrollment_end_and_more.py new file mode 100644 index 0000000000..43172cf146 --- /dev/null +++ b/courses/migrations/0056_program_end_date_program_enrollment_end_and_more.py @@ -0,0 +1,32 @@ +# Generated by Django 4.2 on 2024-09-21 00:17 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("courses", "0055_rename_programrequirement_index"), + ] + + operations = [ + migrations.AddField( + model_name="program", + name="end_date", + field=models.DateField(blank=True, db_index=True, null=True), + ), + migrations.AddField( + model_name="program", + name="enrollment_end", + field=models.DateTimeField(blank=True, db_index=True, null=True), + ), + migrations.AddField( + model_name="program", + name="enrollment_start", + field=models.DateTimeField(blank=True, db_index=True, null=True), + ), + migrations.AddField( + model_name="program", + name="start_date", + field=models.DateField(blank=True, db_index=True, null=True), + ), + ] diff --git a/courses/models.py b/courses/models.py index 227eaecc0b..50fcc0dbca 100644 --- a/courses/models.py +++ b/courses/models.py @@ -161,6 +161,10 @@ class Meta: availability = models.CharField( choices=AVAILABILITY_CHOICES, default=AVAILABILITY_ANYTIME, max_length=255 ) + enrollment_start = models.DateTimeField(null=True, blank=True, db_index=True) + enrollment_end = models.DateTimeField(null=True, blank=True, db_index=True) + start_date = models.DateField(null=True, blank=True, db_index=True) + end_date = models.DateField(null=True, blank=True, db_index=True) @cached_property def page(self): diff --git a/courses/serializers/v2/programs.py b/courses/serializers/v2/programs.py index 5287ebd534..101425c141 100644 --- a/courses/serializers/v2/programs.py +++ b/courses/serializers/v2/programs.py @@ -79,6 +79,10 @@ class Meta: "live", "topics", "availability", + "start_date", + "end_date", + "enrollment_start", + "enrollment_end", ] diff --git a/courses/serializers/v2/programs_test.py b/courses/serializers/v2/programs_test.py index 9575719f3a..49c85f0b41 100644 --- a/courses/serializers/v2/programs_test.py +++ b/courses/serializers/v2/programs_test.py @@ -91,5 +91,9 @@ def test_serialize_program( "live": True, "topics": [{"name": topic.name} for topic in topics], "availability": "anytime", + "start_date": program_with_empty_requirements.start_date, + "end_date": program_with_empty_requirements.end_date, + "enrollment_start": program_with_empty_requirements.enrollment_start, + "enrollment_end": program_with_empty_requirements.enrollment_end, }, )