Skip to content

Commit

Permalink
Merge pull request #1478 from gustavomm19/marketing-cohorts
Browse files Browse the repository at this point in the history
add cohort groups to marketing course
  • Loading branch information
tommygonzaleza authored Nov 4, 2024
2 parents 9a9f6bc + 4dd04a3 commit 6037e56
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 34 deletions.
68 changes: 34 additions & 34 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions breathecode/marketing/migrations/0090_course_cohorts_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 5.1.1 on 2024-10-21 14:03

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("admissions", "0064_academy_legal_name"),
("marketing", "0089_activecampaignacademy_crm_vendor"),
]

operations = [
migrations.AddField(
model_name="course",
name="cohorts_group",
field=models.ManyToManyField(
blank=True,
help_text="The student will be added to this cohorts when he buys the course",
related_name="courses",
to="admissions.cohort",
),
),
]
24 changes: 24 additions & 0 deletions breathecode/marketing/migrations/0091_course_cohorts_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 5.1.2 on 2024-11-01 13:03

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("marketing", "0090_course_cohorts_group"),
]

operations = [
migrations.AddField(
model_name="course",
name="cohorts_order",
field=models.CharField(
blank=True,
default=None,
help_text="An IDs comma separated list to indicate the order in which cohorts in the cohort group will be displayed",
max_length=50,
null=True,
),
),
]
14 changes: 14 additions & 0 deletions breathecode/marketing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,20 @@ class Course(models.Model):
academy = models.ForeignKey(Academy, on_delete=models.CASCADE)
syllabus = models.ManyToManyField(Syllabus, blank=True)
cohort = models.ForeignKey(Cohort, null=True, blank=True, default=None, on_delete=models.CASCADE)
cohorts_group = models.ManyToManyField(
Cohort,
blank=True,
help_text="The student will be added to this cohorts when he buys the course",
related_name="courses",
)

cohorts_order = models.CharField(
max_length=50,
null=True,
blank=True,
default=None,
help_text="An IDs comma separated list to indicate the order in which cohorts in the cohort group will be displayed",
)

plan_slug = models.SlugField(max_length=150, null=True, blank=True, default=None)
status = models.CharField(max_length=15, choices=COURSE_STATUS, default=ACTIVE)
Expand Down
5 changes: 5 additions & 0 deletions breathecode/marketing/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,9 @@ class GetCourseSerializer(GetCourseSmallSerializer):
syllabus = serpy.MethodField()
academy = GetAcademySmallSerializer()
cohort = serpy.MethodField()
cohorts_group = serpy.MethodField()
status = serpy.Field()
cohorts_order = serpy.Field()
visibility = serpy.Field()

def get_syllabus(self, obj):
Expand All @@ -454,6 +456,9 @@ def get_cohort(self, obj):
if obj.cohort:
return GetCohortSmallSerializer(obj.cohort, many=False).data

def get_cohorts_group(self, obj):
return GetCohortSmallSerializer(obj.cohorts_group.all(), many=True).data


class PostFormEntrySerializer(serializers.ModelSerializer):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def test_put_active_campaign(self):
"sync_message": None,
"sync_status": "INCOMPLETED",
"duplicate_leads_delta_avoidance": "00:30:00",
"crm_vendor": "ACTIVE_CAMPAIGN",
**data,
}

Expand Down
2 changes: 2 additions & 0 deletions breathecode/marketing/tests/urls/tests_course.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def get_serializer(course, academy, syllabus=[], course_translation=None, cohort
"syllabus": [syllabus_serializer(x) for x in syllabus],
"plan_slug": course.plan_slug,
"course_translation": course_translation,
"cohorts_group": [],
"cohorts_order": None,
**data,
}

Expand Down
2 changes: 2 additions & 0 deletions breathecode/marketing/tests/urls/tests_course_slug.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def get_serializer(course, academy, syllabus=[], course_translation=None, data={
"status": course.status,
"visibility": course.visibility,
"cohort": course.cohort,
"cohorts_group": [],
"cohorts_order": None,
"color": course.color,
"plan_slug": course.plan_slug,
**data,
Expand Down

0 comments on commit 6037e56

Please sign in to comment.