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 new fields for wordpress filters EDLY-6765 #81

Merged
merged 1 commit into from
May 10, 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
9 changes: 8 additions & 1 deletion course_discovery/apps/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',)

Expand Down Expand Up @@ -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',
)


Expand Down
6 changes: 6 additions & 0 deletions course_discovery/apps/api/tests/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': [],
Expand Down
6 changes: 6 additions & 0 deletions course_discovery/apps/course_metadata/data_loaders/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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'),
),
]
12 changes: 12 additions & 0 deletions course_discovery/apps/course_metadata/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions course_discovery/apps/course_metadata/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down