Skip to content

Commit

Permalink
chore: rename a variable
Browse files Browse the repository at this point in the history
  • Loading branch information
AfaqShuaib09 authored and hamza-56 committed Sep 12, 2024
1 parent 7aff413 commit 0c132e6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def get_products(self, product_type, product_source):
subject_translations
)
elif product_type == 'degree':
queryset = Program.objects.marketable().exclude(degree__isnull=True).select_related('partner', 'type')
queryset = Program.objects.marketable().exclude(degree__isnull=True) \
.select_related('partner', 'type', 'primary_subject_override', 'language_override')

if product_source:
queryset = queryset.filter(product_source__slug=product_source)
Expand Down Expand Up @@ -164,12 +165,12 @@ def get_transformed_data(self, product, product_type):
})
elif product_type == 'degree':
data.update({
"Subjects": ", ".join(subject.name for subject in product.subjects),
"Subjects": ", ".join(subject.name for subject in product.active_subjects),
"Subjects Spanish": ", ".join(
translation.name for subject in product.subjects
for translation in subject.spanish_translations
),
"Languages": ", ".join(language.code for language in product.languages),
"Languages": ", ".join(language.code for language in product.active_languages),
"Marketing Image": product.card_image.url if product.card_image else "",
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ def test_get_transformed_data_for_degree(self):
org.logo_image.url for org in product_authoring_orgs if org.logo_image
),
"Organizations Abbr": ", ".join(org.key for org in product_authoring_orgs),
"Languages": ", ".join(language.code for language in product.languages),
"Subjects": ", ".join(subject.name for subject in product.subjects),
"Languages": ", ".join(language.code for language in product.active_languages),
"Subjects": ", ".join(subject.name for subject in product.active_subjects),
"Subjects Spanish": ", ".join(
translation.name for subject in product.subjects
for translation in subject.spanish_translations
Expand Down
14 changes: 8 additions & 6 deletions course_discovery/apps/course_metadata/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3526,7 +3526,7 @@ def active_languages(self):
"""
if self.language_override:
return {self.language_override}
return {course_run.language for course_run in self.course_runs if course_run.language is not None}
return self.languages

@property
def transcript_languages(self):
Expand Down Expand Up @@ -3558,13 +3558,15 @@ def active_subjects(self):
Note: This method gives preference to the primary_subject_override over the primary subject of the courses.
"""
subjects = self.subjects

if self.primary_subject_override:
if self.primary_subject_override not in self.subjects.all():
product_subjects = [self.primary_subject_override] + list(self.subjects.all())
else:
product_subjects = list(self.subjects.all())
if self.primary_subject_override not in subjects:
subjects = [self.primary_subject_override] + subjects
else:
subjects = [self.primary_subject_override] + [subject for subject in subjects if subject != self.primary_subject_override]

return product_subjects
return subjects

@property
def topics(self):
Expand Down

0 comments on commit 0c132e6

Please sign in to comment.