Skip to content

Commit

Permalink
Merge pull request #131 from CTPUG/bugs/issue-128-slot-deletion-handling
Browse files Browse the repository at this point in the history
Bugs/issue 128 slot deletion handling
  • Loading branch information
drnlm committed Sep 30, 2015
2 parents 86db7a0 + 831b49f commit badf47c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions wafer/schedule/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.core.urlresolvers import reverse
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models.signals import post_save
from django.db.models.signals import post_save, post_delete
from django.utils.encoding import python_2_unicode_compatible

from wafer.snippets.markdown_field import MarkdownTextField
Expand Down Expand Up @@ -170,9 +170,13 @@ def get_details(self):
return self.get_desc()

def get_start_time(self):
start_slot = list(self.slots.all())[0]
start = start_slot.get_start_time().strftime('%H:%M')
return u'%s, %s' % (start_slot.get_day(), start)
slots = list(self.slots.all())
if slots:
start = slots[0].get_start_time().strftime('%H:%M')
day = slots[0].get_day()
return u'%s, %s' % (day, start)
else:
return 'WARNING: No Time and Day Specified'

def __str__(self):
return u'%s in %s at %s' % (self.get_desc(), self.venue,
Expand Down Expand Up @@ -207,3 +211,8 @@ def invalidate_check_schedule(*args, **kw):
post_save.connect(invalidate_check_schedule, sender=Venue)
post_save.connect(invalidate_check_schedule, sender=Slot)
post_save.connect(invalidate_check_schedule, sender=ScheduleItem)

post_delete.connect(invalidate_check_schedule, sender=Day)
post_delete.connect(invalidate_check_schedule, sender=Venue)
post_delete.connect(invalidate_check_schedule, sender=Slot)
post_delete.connect(invalidate_check_schedule, sender=ScheduleItem)

0 comments on commit badf47c

Please sign in to comment.