diff --git a/course_discovery/apps/api/serializers.py b/course_discovery/apps/api/serializers.py index e717b18572..7116d00206 100644 --- a/course_discovery/apps/api/serializers.py +++ b/course_discovery/apps/api/serializers.py @@ -929,7 +929,8 @@ class Meta(MinimalCourseRunSerializer.Meta): 'enrollment_count', 'recent_enrollment_count', 'expected_program_type', 'expected_program_name', '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' + 'average_rating', 'total_raters', 'yt_video_url', 'course_duration_override', 'course_training_packages', + 'course_department', 'course_certifications', 'course_format', 'course_difficulty_level', 'course_language', ) read_only_fields = ('enrollment_count', 'recent_enrollment_count',) @@ -2272,6 +2273,12 @@ class Meta: 'total_raters', 'yt_video_url', 'course_duration_override', + 'course_language', + 'course_training_packages', + 'course_department', + 'course_certifications', + 'course_format', + 'course_difficulty_level', ) diff --git a/course_discovery/apps/api/tests/test_serializers.py b/course_discovery/apps/api/tests/test_serializers.py index 26fc753ff6..e72ced86d5 100644 --- a/course_discovery/apps/api/tests/test_serializers.py +++ b/course_discovery/apps/api/tests/test_serializers.py @@ -652,6 +652,12 @@ def get_expected_data(cls, course_run, request): 'marketing_price_value': course_run.marketing_price_value, 'yt_video_url': course_run.yt_video_url, 'course_duration_override': course_run.course_duration_override, + 'course_training_packages': course_run.course_training_packages, + 'course_department': course_run.course_department, + 'course_certifications': course_run.course_certifications, + 'course_format': course_run.course_format, + 'course_difficulty_level': course_run.course_difficulty_level, + 'course_language' : course_run.course_language, 'is_marketing_price_hidden': course_run.is_marketing_price_hidden, 'card_image_url': course_run.card_image_url, 'subjects': [], diff --git a/course_discovery/apps/course_metadata/data_loaders/api.py b/course_discovery/apps/course_metadata/data_loaders/api.py index a6add42f6a..6fd0245eb5 100644 --- a/course_discovery/apps/course_metadata/data_loaders/api.py +++ b/course_discovery/apps/course_metadata/data_loaders/api.py @@ -1079,6 +1079,12 @@ def _process_response(self, response): course_run.is_marketing_price_hidden = body['hide_price'] course_run.yt_video_url = body['yt_video_url'] course_run.course_duration_override = body['course_duration_override'] + course_run.course_training_packages = body['course_training_packages'] + course_run.course_department = body['course_department'] + course_run.course_certifications = body['course_certifications'] + course_run.course_format = body['course_format'] + course_run.course_difficulty_level = body['course_difficulty_level'] + course_run.course_language = body['course_language'] course_run.status = self._process_course_status(body['status']) course_run.tags.clear() diff --git a/course_discovery/apps/course_metadata/migrations/0271_auto_20240507_0825.py b/course_discovery/apps/course_metadata/migrations/0271_auto_20240507_0825.py new file mode 100644 index 0000000000..e6064eaf50 --- /dev/null +++ b/course_discovery/apps/course_metadata/migrations/0271_auto_20240507_0825.py @@ -0,0 +1,73 @@ +# Generated by Django 2.2.16 on 2024-05-07 08:25 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('course_metadata', '0270_auto_20231024_0956'), + ] + + operations = [ + migrations.AddField( + model_name='courserun', + name='course_certifications', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Course Certifications'), + ), + migrations.AddField( + model_name='courserun', + name='course_department', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Course Department'), + ), + migrations.AddField( + model_name='courserun', + name='course_difficulty_level', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Course Difficulty Level'), + ), + migrations.AddField( + model_name='courserun', + name='course_format', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Course Format'), + ), + migrations.AddField( + model_name='courserun', + name='course_language', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Course Language'), + ), + migrations.AddField( + model_name='courserun', + name='course_training_packages', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Course Training Packages'), + ), + migrations.AddField( + model_name='historicalcourserun', + name='course_certifications', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Course Certifications'), + ), + migrations.AddField( + model_name='historicalcourserun', + name='course_department', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Course Department'), + ), + migrations.AddField( + model_name='historicalcourserun', + name='course_difficulty_level', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Course Difficulty Level'), + ), + migrations.AddField( + model_name='historicalcourserun', + name='course_format', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Course Format'), + ), + migrations.AddField( + model_name='historicalcourserun', + name='course_language', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Course Language'), + ), + migrations.AddField( + model_name='historicalcourserun', + name='course_training_packages', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Course Training Packages'), + ), + ] diff --git a/course_discovery/apps/course_metadata/models.py b/course_discovery/apps/course_metadata/models.py index da1168b4f0..3eebd20e52 100644 --- a/course_discovery/apps/course_metadata/models.py +++ b/course_discovery/apps/course_metadata/models.py @@ -1327,6 +1327,18 @@ class CourseRun(DraftModelMixin, CachedMixin, TimeStampedModel): null=True, blank=True, help_text=_('This field contains override course duration value.'), verbose_name=_('Course Duration Override') ) + course_training_packages = models.CharField( + max_length=255, null=True, blank=True, verbose_name=_('Course Training Packages')) + course_department = models.CharField( + max_length=255, null=True, blank=True, verbose_name=_('Course Department')) + course_certifications = models.CharField( + max_length=255, null=True, blank=True, verbose_name=_('Course Certifications')) + course_format = models.CharField( + max_length=255, null=True, blank=True, verbose_name=_('Course Format')) + course_difficulty_level = models.CharField( + max_length=255, null=True, blank=True, verbose_name=_('Course Difficulty Level')) + course_language = models.CharField( + max_length=255, null=True, blank=True, verbose_name=_('Course Language')) STATUS_CHANGE_EXEMPT_FIELDS = [ 'start', diff --git a/course_discovery/apps/course_metadata/search_indexes.py b/course_discovery/apps/course_metadata/search_indexes.py index 2ec85734ef..b9e5c83ee8 100644 --- a/course_discovery/apps/course_metadata/search_indexes.py +++ b/course_discovery/apps/course_metadata/search_indexes.py @@ -254,6 +254,12 @@ class CourseRunIndex(BaseCourseIndex, indexes.Indexable): total_raters = indexes.IntegerField(model_attr='total_raters', null=True) yt_video_url = indexes.CharField(model_attr='yt_video_url', null=True) course_duration_override = indexes.IntegerField(model_attr='course_duration_override', null=True) + course_training_packages = indexes.CharField(model_attr='course_training_packages', null=True) + course_department = indexes.CharField(model_attr='course_department', null=True) + course_certifications = indexes.CharField(model_attr='course_certifications', null=True) + course_format = indexes.CharField(model_attr='course_format', null=True) + course_difficulty_level = indexes.CharField(model_attr='course_difficulty_level', null=True) + course_language = indexes.CharField(model_attr='course_language', null=True) def read_queryset(self, using=None): # Pre-fetch all fields required by the CourseRunSearchSerializer. Unfortunately, there's