agenda: checking if the event object has "act" attribute

This commit is contained in:
Serghei Mihai 2014-07-07 09:42:34 +02:00
parent 9cfc3afc04
commit 8a5069a6a0
1 changed files with 11 additions and 5 deletions

View File

@ -277,12 +277,18 @@ class UpdatePeriodicEventView(BaseEventView):
def delete_eventwithact(event):
assert event.event_type_id == 1
if event.act.id \
and not event.act.is_billed:
event.act.delete()
if not event.act.id or \
not event.act.is_billed:
# in case of "event" is an instance of "Event" model and not "EventWithAct"
# and so doesn't have 'act' attribute
try:
if event.act.id \
and not event.act.is_billed:
event.act.delete()
if not event.act.id or \
not event.act.is_billed:
event.delete()
except AttributeError:
event.delete()
class DeleteOccurrenceView(TodayOccurrenceMixin, cbv.DeleteView):