def get_duty_officers(at_time=None):
 duty_officers = []
 if (not at_time):
  at_time = timezone.now()
 current_shifts = Shift.objects.filter(deleted=False, start__lt=at_time, end__gt=at_time)
 if current_shifts:
  duty_officers = [shift.user for shift in current_shifts]
  return duty_officers
 else:
  try:
   u = UserProfile.objects.get(fallback_alert_user=True)
   return [u.user]
  except UserProfile.DoesNotExist:
   return []

def get_duty_officers ( at_time = None ) : duty_officers = [ ] if ( not at_time ) : at_time = timezone . now ( ) current_shifts = Shift . objects . filter ( deleted = False , start__lt = at_time , end__gt = at_time ) if current_shifts : duty_officers = [ shift . user for shift in current_shifts ] return duty_officers else : try : u = UserProfile . objects . get ( fallback_alert_user = True ) return [ u . user ] except UserProfile . DoesNotExist : return [ ]
returns a list of duty officers for a given time or now if none given .