Permalink
Browse files

Assume full availability if there is no AvailabilityModule

For programs that are not using the AvailabilityModule (assuming that
teachers are always available), it's an annoyance when the Web site
complains the teachers aren't available.  This should fix that by checking
for the existence of an AvailabilityModule in ESPUser.getAvailableTimes().
  • Loading branch information...
pricem committed Jun 13, 2012
1 parent 3c47c39 commit 349a1dd8ccc75e7ead7d8797df2cfe688c5f900c
Showing with 7 additions and 1 deletion.
  1. +7 −1 esp/esp/users/models/__init__.py
@@ -481,7 +481,12 @@ def getAvailableTimes(self, program, ignore_classes=False):
can teach for a particular program. """
from esp.cal.models import Event
- valid_events = Event.objects.filter(useravailability__user=self, anchor=program.anchor).order_by('start')
+ # Detect whether the program has the availability module, and assume
+ # the user is always available if it isn't there.
+ if program.program_modules.filter(handler='AvailabilityModule').exists():
+ valid_events = Event.objects.filter(useravailability__user=self, anchor=program.anchor).order_by('start')
+ else:
+ valid_events = program.getTimeSlots()
if not ignore_classes:
# Subtract out the times that they are already teaching.
@@ -499,6 +504,7 @@ def getAvailableTimes(self, program, ignore_classes=False):
# FIXME: Really should take into account section's teachers...
# even though that shouldn't change often
getAvailableTimes.depend_on_m2m(lambda:ClassSection, 'meeting_times', lambda sec, event: {'program': sec.parent_program})
+ getAvailableTimes.depend_on_m2m(lambda:Program, 'program_modules', lambda prog, pm: {'program': prog})
getAvailableTimes.depend_on_row(lambda:UserAvailability, lambda ua:
# FIXME: What if resource.event.anchor somehow isn't a program?
# Probably want a helper method return a special "nothing" object (XXX: NOT None)

0 comments on commit 349a1dd

Please sign in to comment.