FIX #35 and #36: add new event stati canceled and realized
Some checks failed
buildbot/tox Build done.

This commit is contained in:
2021-01-07 12:52:21 +01:00
parent 642971e469
commit 269d59f460
10 changed files with 164 additions and 8 deletions

View File

@@ -31,6 +31,8 @@ DEFAULT_EVENT_STATI = {
'published_web': (79, _(u'Veröffentlicht (Web)'), 'success'),
'published': (80, _(u'Veröffentlicht'), 'success'),
'expired': (100, _(u'Ausgelaufen'), None),
'canceled': (101, _(u'Abgesagt'), 'dav-mandarin'),
'realized': (102, _(u'Durchgeführt'), 'dav-lime'),
'cleared': (110, _(u'Abgerechnet'), 'black'),
}
@@ -216,6 +218,24 @@ class BasicWorkflow(object):
valid = False
return_code = 'not-accepted'
message = u'Event is not accepted.'
elif code.startswith('cancel'):
if not self.has_reached_status('submitted'):
valid = False
return_code = 'not-submitted'
message = u'Event is not submitted.'
elif self.has_reached_status('realized'):
valid = False
return_code = 'already-realized'
message = u'Event was already realized.'
elif code.startswith('realize'):
if event.first_day <= today:
valid = False
return_code = 'not-started'
message = u'Event has not begun.'
elif not self.has_reached_status('accepted'):
valid = False
return_code = 'not-accepted'
message = u'Event is not accepted.'
if callback is not None:
callback(valid, return_code, message, *args, **kwargs)
@@ -400,6 +420,16 @@ class BasicWorkflow(object):
email = emails.EventToPublishFacebookMail(recipient=recipient, event=event, editor=updater,
confirm_publication_action=action)
email.send()
elif flag.status.code == 'canceled':
# Who should be informed about the cancelation?
recipients = [event.owner]
recipients += get_users_by_role('manager_super')
recipients += get_users_by_role('office')
for recipient in recipients:
if recipient.email and recipient.email != updater.email:
email = emails.EventCanceledMail(recipient=recipient, event=event, editor=updater)
email.send()
#
# Permissions
@@ -432,6 +462,16 @@ class BasicWorkflow(object):
elif permission == 'publish':
if has_role(user, 'publisher'):
return True
elif permission == 'cancel':
if user == event.owner:
return True
if has_role(user, 'manager_super'):
return True
if has_role(user, 'office'):
return True
elif permission == 'realize':
if user == event.owner:
return True
elif permission == 'clear':
if has_role(user, 'manager_super'):
return True