Skip to content

Commit

Permalink
refactor: [AXM-288] Refactor get_course_assignments
Browse files Browse the repository at this point in the history
Co-authored-by: monteri <[email protected]>
  • Loading branch information
2 people authored and monteri committed Apr 24, 2024
1 parent b6f12cb commit f53aff4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lms/djangoapps/mobile_api/users/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,13 @@ def get_course_assignments(self, model: CourseEnrollment) -> Dict[str, Optional[
if not assignment.complete:
next_assignment_all.append(assignment)

if next_assignment_all:
future_assignment_date = next_assignment_all[0].date.date()
next_assignment = [
assignment for assignment in next_assignment_all if assignment.date.date() == future_assignment_date
]
if future_assignments:
future_assignment_date = future_assignments[0].date.date()
next_assignments = [
assignment for assignment in future_assignments if assignment.date.date() == future_assignment_date
]
else:
next_assignments = []

return {
'future_assignments': DateSummarySerializer(next_assignment, many=True).data,
Expand Down

0 comments on commit f53aff4

Please sign in to comment.