Skip to content

Commit

Permalink
Refactor leave filtering in get_calendar() function to exclude rejected
Browse files Browse the repository at this point in the history
  • Loading branch information
Tubo committed Feb 23, 2024
1 parent 5ad3e81 commit 3ceb302
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions radscheduler/core/views/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ def get_calendar(request):
shifts = Shift.objects.filter(date__gte=start, date__lte=end, registrar__isnull=False).select_related(
"registrar", "registrar__user"
)
leaves = Leave.objects.filter(date__gte=start, date__lte=end, cancelled=False).select_related(
"registrar", "registrar__user"
leaves = (
Leave.objects.filter(date__gte=start, date__lte=end, cancelled=False)
.exclude(reg_approved=False)
.exclude(dot_approved=False)
.select_related("registrar", "registrar__user")
)
events = shifts_to_events(shifts) + leaves_to_events(leaves) + holidays_to_events(start.year)
return JsonResponse(events, safe=False)
Expand Down

0 comments on commit 3ceb302

Please sign in to comment.