Skip to content

Commit

Permalink
feat: Add new fields for wordpress cymanii filters EDLY-6765 (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfarhan943 authored May 22, 2024
1 parent fb441f0 commit 27360ec
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 1 deletion.
8 changes: 7 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_difficulty',
'course_job_role', 'course_format', 'course_industry_certified_training', 'course_owner'
)
read_only_fields = ('enrollment_count', 'recent_enrollment_count',)

Expand Down Expand Up @@ -2272,6 +2273,11 @@ class Meta:
'total_raters',
'yt_video_url',
'course_duration_override',
'course_difficulty',
'course_job_role',
'course_format',
'course_industry_certified_training',
'course_owner',
)


Expand Down
5 changes: 5 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,11 @@ 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_difficulty': course_run.course_difficulty,
'course_job_role': course_run.course_job_role,
'course_format': course_run.course_format,
'course_industry_certified_training': course_run.course_industry_certified_training,
'course_owner': course_run.course_owner,
'is_marketing_price_hidden': course_run.is_marketing_price_hidden,
'card_image_url': course_run.card_image_url,
'subjects': [],
Expand Down
5 changes: 5 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,11 @@ 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_difficulty = body['course_difficulty']
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_owner = body['course_owner']
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,63 @@
# Generated by Django 2.2.16 on 2024-05-21 11:54

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_difficulty',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Course Difficulty'),
),
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_industry_certified_training',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='CourseIndustry Certified Training'),
),
migrations.AddField(
model_name='courserun',
name='course_job_role',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Course Job Roles'),
),
migrations.AddField(
model_name='courserun',
name='course_owner',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Course Owner'),
),
migrations.AddField(
model_name='historicalcourserun',
name='course_difficulty',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Course Difficulty'),
),
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_industry_certified_training',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='CourseIndustry Certified Training'),
),
migrations.AddField(
model_name='historicalcourserun',
name='course_job_role',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Course Job Roles'),
),
migrations.AddField(
model_name='historicalcourserun',
name='course_owner',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Course Owner'),
),
]
18 changes: 18 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,24 @@ class CourseRun(DraftModelMixin, CachedMixin, TimeStampedModel):
null=True, blank=True, help_text=_('This field contains override course duration value.'),
verbose_name=_('Course Duration Override')
)
course_difficulty = models.CharField(
max_length=255, null=True, blank=True, verbose_name=_("Course Difficulty")
)
course_job_role = models.CharField(
max_length=255, null=True, blank=True, verbose_name=_("Course Job Roles")
)
course_format = models.CharField(
max_length=255, null=True, blank=True, verbose_name=_("Course Format")
)
course_industry_certified_training = models.CharField(
max_length=255,
null=True,
blank=True,
verbose_name=_("CourseIndustry Certified Training"),
)
course_owner = models.CharField(
max_length=255, null=True, blank=True, verbose_name=_("Course Owner")
)

STATUS_CHANGE_EXEMPT_FIELDS = [
'start',
Expand Down
5 changes: 5 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,11 @@ 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_difficulty = indexes.CharField(model_attr='course_difficulty', null=True)
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_owner = indexes.CharField(model_attr='course_owner', null=True)

def read_queryset(self, using=None):
# Pre-fetch all fields required by the CourseRunSearchSerializer. Unfortunately, there's
Expand Down

0 comments on commit 27360ec

Please sign in to comment.