Skip to content

Commit

Permalink
Add availability to programs in models.py (#2322)
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
JenniWhitman and pre-commit-ci[bot] authored Aug 27, 2024
1 parent 0ec42b9 commit b9b6522
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions courses/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@
HOMEPAGE_CACHE_AGE = 86400 # 24 hours

SYNCED_COURSE_RUN_FIELD_MSG = "This value is synced automatically with edX studio."

AVAILABILITY_ANYTIME = "anytime"
AVAILABILITY_DATED = "dated"
AVAILABILITY_TYPES = {AVAILABILITY_ANYTIME, AVAILABILITY_DATED}
AVAILABILITY_CHOICES = list(zip(AVAILABILITY_TYPES, AVAILABILITY_TYPES))
1 change: 1 addition & 0 deletions courses/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ class Meta:
"departments",
"live",
"requirements",
"availability",
]

class Media:
Expand Down
21 changes: 21 additions & 0 deletions courses/migrations/0052_add_program_availability.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.2.25 on 2024-08-02 02:30

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("courses", "0051_coursestopic"),
]

operations = [
migrations.AddField(
model_name="program",
name="availability",
field=models.CharField(
choices=[("anytime", "anytime"), ("dated", "dated")],
default="anytime",
max_length=255,
),
),
]
5 changes: 5 additions & 0 deletions courses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
from wagtail.models import Revision

from courses.constants import (
AVAILABILITY_ANYTIME,
AVAILABILITY_CHOICES,
ENROLL_CHANGE_STATUS_CHOICES,
ENROLLABLE_ITEM_ID_SEPARATOR,
SYNCED_COURSE_RUN_FIELD_MSG,
Expand Down Expand Up @@ -156,6 +158,9 @@ class Meta:
null=True,
)
departments = models.ManyToManyField(Department, blank=False)
availability = models.CharField(
choices=AVAILABILITY_CHOICES, default=AVAILABILITY_ANYTIME, max_length=255
)

@cached_property
def page(self):
Expand Down
1 change: 1 addition & 0 deletions courses/serializers/v2/programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class Meta:
"departments",
"live",
"topics",
"availability",
]


Expand Down
1 change: 1 addition & 0 deletions courses/serializers/v2/programs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,6 @@ def test_serialize_program(
"departments": [],
"live": True,
"topics": [{"name": topic.name} for topic in topics],
"availability": "anytime",
},
)

0 comments on commit b9b6522

Please sign in to comment.