Skip to content

Commit

Permalink
Adding dates on Program model (#2404)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
annagav and pre-commit-ci[bot] authored Sep 26, 2024
1 parent c72e940 commit 576e352
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion courses/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]


Expand Down
Original file line number Diff line number Diff line change
@@ -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),
),
]
4 changes: 4 additions & 0 deletions courses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 4 additions & 0 deletions courses/serializers/v2/programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ class Meta:
"live",
"topics",
"availability",
"start_date",
"end_date",
"enrollment_start",
"enrollment_end",
]


Expand Down
4 changes: 4 additions & 0 deletions courses/serializers/v2/programs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
)

0 comments on commit 576e352

Please sign in to comment.