Skip to content

Commit

Permalink
fix: adding status to minimal serializers (#4261)
Browse files Browse the repository at this point in the history
* fix: adding status to minimal serializers

* fix: removing debugging crust
  • Loading branch information
kiram15 authored Feb 7, 2024
1 parent 82409e3 commit c733b1b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
11 changes: 6 additions & 5 deletions course_discovery/apps/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,7 @@ class MinimalCourseSerializer(FlexFieldsSerializerMixin, TimestampModelSerialize
url_slug = serializers.SerializerMethodField()
course_type = serializers.SerializerMethodField()
enterprise_subscription_inclusion = serializers.BooleanField(required=False)
course_run_statuses = serializers.ReadOnlyField()

@classmethod
def prefetch_queryset(cls, queryset=None, course_runs=None):
Expand Down Expand Up @@ -1212,7 +1213,7 @@ class Meta:
model = Course
fields = ('key', 'uuid', 'title', 'course_runs', 'entitlements', 'owners', 'image',
'short_description', 'type', 'url_slug', 'course_type', 'enterprise_subscription_inclusion',
'excluded_from_seo', 'excluded_from_search')
'excluded_from_seo', 'excluded_from_search', 'course_run_statuses')


class CourseEditorSerializer(serializers.ModelSerializer):
Expand Down Expand Up @@ -1969,6 +1970,7 @@ class MinimalProgramSerializer(TaggitSerializer, FlexFieldsSerializerMixin, Base
degree = DegreeSerializer()
curricula = CurriculumSerializer(many=True)
card_image_url = serializers.SerializerMethodField()
course_run_statuses = serializers.ReadOnlyField()
organization_short_code_override = serializers.CharField(required=False, allow_blank=True)
organization_logo_override_url = serializers.SerializerMethodField()
primary_subject_override = SubjectSerializer()
Expand Down Expand Up @@ -2012,8 +2014,8 @@ class Meta:
'total_hours_of_effort', 'recent_enrollment_count', 'organization_short_code_override',
'organization_logo_override_url', 'primary_subject_override', 'level_type_override', 'language_override',
'labels', 'taxi_form', 'program_duration_override', 'data_modified_timestamp',
'excluded_from_search', 'excluded_from_seo', 'subscription', 'has_ofac_restrictions', 'ofac_comment'

'excluded_from_search', 'excluded_from_seo', 'subscription', 'has_ofac_restrictions', 'ofac_comment',
'course_run_statuses',
)
read_only_fields = (
'uuid', 'marketing_url', 'banner_image', 'data_modified_timestamp', 'has_ofac_restrictions', 'ofac_comment'
Expand Down Expand Up @@ -2197,7 +2199,6 @@ class ProgramSerializer(MinimalProgramSerializer):
skill_names = serializers.SerializerMethodField()
skills = serializers.SerializerMethodField()
product_source = SourceSerializer(required=False, read_only=True)
course_run_statuses = serializers.ReadOnlyField()

@classmethod
def prefetch_queryset(cls, partner, queryset=None):
Expand Down Expand Up @@ -2259,7 +2260,7 @@ class Meta(MinimalProgramSerializer.Meta):
'staff', 'credit_redemption_overview', 'applicable_seat_types', 'instructor_ordering',
'enrollment_count', 'topics', 'credit_value', 'enterprise_subscription_inclusion', 'geolocation',
'location_restriction', 'is_2u_degree_program', 'in_year_value', 'skill_names', 'skills',
'product_source', 'excluded_from_search', 'excluded_from_seo', 'course_run_statuses',
'product_source', 'excluded_from_search', 'excluded_from_seo',
)
read_only_fields = ('enterprise_subscription_inclusion', 'product_source',)

Expand Down
2 changes: 2 additions & 0 deletions course_discovery/apps/api/tests/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def get_expected_data(cls, course, course_skill, request): # pylint: disable=un
'course_type': course.type.slug,
'enterprise_subscription_inclusion': course.enterprise_subscription_inclusion,
'url_slug': None,
'course_run_statuses': course.course_run_statuses,
}

def test_data(self):
Expand Down Expand Up @@ -1095,6 +1096,7 @@ def get_expected_data(cls, program, request, include_labels=True):
'ofac_comment': program.ofac_comment,
'subscription_eligible': None,
'subscription_prices': [],
'course_run_statuses': program.course_run_statuses,
}

def test_data(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,6 @@ def test_typeahead_authoring_organizations_partial_search(self):

def test_typeahead_org_course_runs_come_up_first(self):
""" Test typeahead response to ensure org is taken into account. """
self.maxDiff = None
MITx = OrganizationFactory(key='MITx')
HarvardX = OrganizationFactory(key='HarvardX')
mit_run = CourseRunFactory(
Expand Down
1 change: 0 additions & 1 deletion course_discovery/apps/course_metadata/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,6 @@ class UtilsTests(TestCase):
@ddt.unpack
def test_clean_html(self, content, expected):
""" Verify the method removes unnecessary HTML attributes. """
self.maxDiff = None
assert clean_html(content) == expected

def test_skill_data_transformation(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def test_data(self):
"""
Tests serializer Data.
"""
self.maxDiff = None
recommendation = CourseRecommendationFactory()
serializer = self.serializer_class(recommendation)
expected = self.get_expected_data(recommendation)
Expand Down

0 comments on commit c733b1b

Please sign in to comment.