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

Feat: Add a additional language in the courserun API model. #89

Merged
merged 1 commit into from
Sep 2, 2024
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
3 changes: 2 additions & 1 deletion course_discovery/apps/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ class Meta(MinimalCourseRunSerializer.Meta):
'course_uuid', 'estimated_hours', 'invite_only', 'subjects',
'is_marketing_price_set', 'marketing_price_value', 'is_marketing_price_hidden', 'featured', 'card_image_url',
'average_rating', 'total_raters', 'yt_video_url', 'course_duration_override', 'course_difficulty',
'course_job_role', 'course_format', 'course_industry_certified_training', 'course_owner'
'course_job_role', 'course_format', 'course_industry_certified_training', 'course_owner', 'course_language'
)
read_only_fields = ('enrollment_count', 'recent_enrollment_count',)

Expand Down Expand Up @@ -2278,6 +2278,7 @@ class Meta:
'course_format',
'course_industry_certified_training',
'course_owner',
'course_language'
)


Expand Down
1 change: 1 addition & 0 deletions course_discovery/apps/api/tests/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ def get_expected_data(cls, course_run, request):
'is_marketing_price_hidden': course_run.is_marketing_price_hidden,
'card_image_url': course_run.card_image_url,
'subjects': [],
'course_language': course_run.course_language
})
return expected

Expand Down
1 change: 1 addition & 0 deletions course_discovery/apps/course_metadata/data_loaders/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,7 @@ def _process_response(self, response):
course_run.course_job_role = body['course_job_role']
course_run.course_format = body['course_format']
course_run.course_industry_certified_training = body['course_industry_certified_training']
course_run.course_language = body['course_language']
course_run.course_owner = body['course_owner']
course_run.status = self._process_course_status(body['status'])

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 2.2.16 on 2024-08-30 11:41

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('course_metadata', '0271_auto_20240521_1154'),
]

operations = [
migrations.AddField(
model_name='courserun',
name='course_language',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Language of the course run'),
),
migrations.AddField(
model_name='historicalcourserun',
name='course_language',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Language of the course run'),
),
]
7 changes: 7 additions & 0 deletions course_discovery/apps/course_metadata/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,13 @@ class CourseRun(DraftModelMixin, CachedMixin, TimeStampedModel):
max_length=255, null=True, blank=True, verbose_name=_("Course Owner")
)

course_language = models.CharField(
max_length=255,
null=True,
blank=True,
verbose_name=_("Language of the course run"),
)

STATUS_CHANGE_EXEMPT_FIELDS = [
'start',
'end',
Expand Down
2 changes: 2 additions & 0 deletions course_discovery/apps/course_metadata/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ class CourseRunIndex(BaseCourseIndex, indexes.Indexable):
course_job_role = indexes.CharField(model_attr='course_job_role', null=True)
course_format = indexes.CharField(model_attr='course_format', null=True)
course_industry_certified_training = indexes.CharField(model_attr='course_industry_certified_training', null=True)
course_language = indexes.CharField(model_attr='course_language', null=True)

mfarhan943 marked this conversation as resolved.
Show resolved Hide resolved
course_owner = indexes.CharField(model_attr='course_owner', null=True)

def read_queryset(self, using=None):
Expand Down