Skip to content

Commit

Permalink
Don't clear teacher interview or training signups when editing class …
Browse files Browse the repository at this point in the history
…availability (fix #2071) (#2093)

Make clearAvailableTimes() clear only Class Time Block events, not all events (for a particular teacher and program). This fixes #2071.
  • Loading branch information
hwatheod authored and benjaminjkraft committed Apr 8, 2016
1 parent a77ccbb commit 1b1d847
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions esp/esp/users/models/__init__.py
Expand Up @@ -64,7 +64,7 @@



from esp.cal.models import Event
from esp.cal.models import Event, EventType
from argcache import cache_function, wildcard
from esp.customforms.linkfields import CustomFormsLinkModel
from esp.customforms.forms import AddressWidget, NameWidget
Expand Down Expand Up @@ -494,8 +494,12 @@ def getAvailableTimes(self, program, ignore_classes=False):
# though Event shouldn't change much

def clearAvailableTimes(self, program):
""" Clear this teacher's availability for a program """
self.useravailability_set.filter(event__program=program).delete()
""" Clear this teacher's class availability (but not interviews, etc.) for a program """
try:
class_time_block_event_type = EventType.objects.get(description='Class Time Block')
except EventType.DoesNotExist:
raise ESPError('There is no Class Time Block event type; this should always be there!')
self.useravailability_set.filter(event__program=program, event__event_type=class_time_block_event_type).delete()

def addAvailableTime(self, program, timeslot, role=None):
# Because the timeslot has a program, the program is unnecessary.
Expand Down

0 comments on commit 1b1d847

Please sign in to comment.