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

Improve get_normalized_metadata_for_assignment logic to prevent duplicate cousre notification emails #580

Closed
wants to merge 1 commit into from
Closed
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
17 changes: 12 additions & 5 deletions enterprise_access/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,18 @@ 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', {})

normalized_metadata_by_run = content_metadata.get('normalized_metadata_by_run', {})
return normalized_metadata_by_run.get(assignment.content_key, {})
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 with a perferred coruse run key
normalized_metadata = content_metadata.get('normalized_metadata_by_run', {})
return normalized_metadata.get(assignment.preferred_course_run_key, {})
else:
# Old style assignment assigned by a course key
normalized_metadata_by_run = content_metadata.get('normalized_metadata', {})
return normalized_metadata_by_run.get(assignment.content_key, {})


def _curr_date(date_format=None):
Expand Down
Loading