Skip to content

Commit

Permalink
chore: Improve get_normalized_metadata_for_assignment prevent duplica…
Browse files Browse the repository at this point in the history
…te cousre notification emails
  • Loading branch information
macdiesel committed Oct 31, 2024
1 parent adf1f85 commit a9d87ff
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions enterprise_access/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,21 @@ def get_normalized_metadata_for_assignment(assignment, content_metadata):
Returns:
dict: Normalized metadata, either for a specific course run or the advertised course run, if any.
"""
if not assignment.is_assigned_course_run:
return content_metadata.get('normalized_metadata', {})
if assignment.is_assigned_course_run:
# Course run-based assignment
normalized_metadata_by_run = content_metadata.get('normalized_metadata_by_run', {})
return normalized_metadata_by_run.get(assignment.content_key, {})
elif assignment.preferred_course_run_key:
# Course-based assignment
normalized_metadata = content_metadata.get('normalized_metadata', {})
return normalized_metadata.get(assignment.preferred_course_run_key, {})
else:
# what is this case?
normalized_metadata_by_run = content_metadata.get('normalized_metadata', {})
return normalized_metadata_by_run.get(assignment.content_key, {})



normalized_metadata_by_run = content_metadata.get('normalized_metadata_by_run', {})
return normalized_metadata_by_run.get(assignment.content_key, {})


def _curr_date(date_format=None):
Expand Down

0 comments on commit a9d87ff

Please sign in to comment.