Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add micro cohorts to public cohort serializer #1523

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions breathecode/admissions/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ class PublicCohortSerializer(serpy.Serializer):
name = serpy.Field()
never_ends = serpy.Field()
private = serpy.Field()
micro_cohorts = serpy.MethodField()
language = serpy.Field()
kickoff_date = serpy.Field()
ending_date = serpy.Field()
Expand All @@ -387,6 +388,10 @@ def get_distance(self, obj):

return haversine(obj.longitude, obj.latitude, obj.academy.longitude, obj.academy.latitude)

def get_micro_cohorts(self, obj):
cohorts = obj.micro_cohorts.all()
return GetTinyCohortSerializer(cohorts, many=True).data


class GetSmallCohortSerializer(serpy.Serializer):
"""The serializer schema definition."""
Expand Down
1 change: 1 addition & 0 deletions breathecode/admissions/tests/urls/tests_cohort_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def get_serializer(cohort, syllabus, syllabus_version, data={}):
re.sub(r"\+00:00$", "Z", cohort.kickoff_date.isoformat()) if cohort.kickoff_date else cohort.kickoff_date
),
"ending_date": cohort.ending_date,
"micro_cohorts": [],
"language": cohort.language.lower(),
"remote_available": cohort.remote_available,
"syllabus_version": {
Expand Down
Loading