Publish workflow is now fully functional.
This commit is contained in:
@@ -46,14 +46,14 @@ class Event(models.Model):
|
||||
blank=True,
|
||||
null=True,
|
||||
default=None)
|
||||
published = models.BooleanField(default=False)
|
||||
published_at = models.DateTimeField(blank=True,
|
||||
null=True)
|
||||
published_by = models.ForeignKey(settings.AUTH_USER_MODEL,
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=models.SET(get_ghost_user),
|
||||
related_name='+')
|
||||
publication_confirmed = models.BooleanField(default=False)
|
||||
publication_confirmed_at = models.DateTimeField(blank=True,
|
||||
null=True)
|
||||
publication_confirmed_by = models.ForeignKey(settings.AUTH_USER_MODEL,
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=models.SET(get_ghost_user),
|
||||
related_name='+')
|
||||
|
||||
# DescriptionForm
|
||||
title = models.CharField(max_length=config.TITLE_MAX_LENGTH)
|
||||
@@ -163,8 +163,8 @@ class Event(models.Model):
|
||||
blank=True)
|
||||
|
||||
# SummaryForm
|
||||
planned_publish_date = models.DateField(blank=True,
|
||||
null=True)
|
||||
planned_publication_date = models.DateField(blank=True,
|
||||
null=True)
|
||||
internal_note = models.TextField(blank=True)
|
||||
|
||||
class Meta:
|
||||
@@ -235,7 +235,7 @@ class Event(models.Model):
|
||||
action = OneClickAction(command='EP')
|
||||
action.parameters = '{event},{user}'.format(event=self.id, user=user.id)
|
||||
action.save()
|
||||
email = emails.EventToPublishMail(recipient=user, event=self, set_published_action=action)
|
||||
email = emails.EventToPublishMail(recipient=user, event=self, confirm_publication_action=action)
|
||||
email.send()
|
||||
|
||||
email = emails.EventAcceptedMail(recipient=self.owner, event=self)
|
||||
@@ -245,35 +245,37 @@ class Event(models.Model):
|
||||
else:
|
||||
return None
|
||||
|
||||
def set_published(self, user=None):
|
||||
def confirm_publication(self, user=None):
|
||||
if not self.accepted:
|
||||
logger.warning('Event.set_published(): event is not accepted yet! (Event: %s)', self.event)
|
||||
logger.warning('Event.confirm_publication(): event is not accepted yet! (Event: %s)', self.event)
|
||||
|
||||
if not self.published:
|
||||
self.published = True
|
||||
self.published_at = timezone.now()
|
||||
if not self.publication_confirmed:
|
||||
self.publication_confirmed = True
|
||||
self.publication_confirmed_at = timezone.now()
|
||||
if user:
|
||||
self.published_by = user
|
||||
self.publication_confirmed_by = user
|
||||
else:
|
||||
logger.warning('Event.set_published(): no user given! (Event: %s)', self.event)
|
||||
logger.warning('Event.confirm_publication(): no user given! (Event: %s)', self.event)
|
||||
self.save()
|
||||
logger.info('Event is published: %s', self)
|
||||
|
||||
def get_status(self):
|
||||
now = datetime.date.today()
|
||||
today = datetime.date.today()
|
||||
if self.alt_last_day:
|
||||
if self.alt_last_day < now:
|
||||
if self.alt_last_day < today:
|
||||
return 'expired'
|
||||
elif self.last_day:
|
||||
if self.last_day < now:
|
||||
if self.last_day < today:
|
||||
return 'expired'
|
||||
elif self.alt_first_day:
|
||||
if self.alt_first_day < now:
|
||||
if self.alt_first_day < today:
|
||||
return 'expired'
|
||||
elif self.first_day and self.first_day < now:
|
||||
elif self.first_day and self.first_day < today:
|
||||
return 'expired'
|
||||
|
||||
if self.published:
|
||||
if self.publication_confirmed and self.planned_publication_date and self.planned_publication_date > today:
|
||||
return 'publishing'
|
||||
elif self.publication_confirmed:
|
||||
return 'published'
|
||||
elif self.accepted:
|
||||
return 'accepted'
|
||||
@@ -413,7 +415,7 @@ class Event(models.Model):
|
||||
'trainer_3_email': self.trainer_3_email,
|
||||
'trainer_3_phone': self.trainer_3_phone,
|
||||
'registration_howto': self.registration_howto,
|
||||
'planned_publish_date': self.planned_publish_date,
|
||||
'planned_publication_date': self.planned_publication_date,
|
||||
'internal_note': self.internal_note,
|
||||
}
|
||||
return context
|
||||
@@ -432,7 +434,7 @@ class Event(models.Model):
|
||||
class OneClickAction(models.Model):
|
||||
COMMANDS = (
|
||||
('EA', 'accept event'),
|
||||
('EP', 'report publishing of an event'),
|
||||
('EP', 'confirm publication of an event'),
|
||||
('EL', 'login and go to event list')
|
||||
)
|
||||
|
||||
@@ -512,16 +514,16 @@ class OneClickAction(models.Model):
|
||||
event_id, user_id = self.parameters.split(',')
|
||||
event = Event.objects.get(id=event_id)
|
||||
user = get_user_model().objects.get(id=user_id)
|
||||
if event.published:
|
||||
if event.publication_confirmed:
|
||||
status = 'info'
|
||||
message = (ugettext(u'Veröffentlichung wurde bereits von %(fullname)s bestätigt.') %
|
||||
{'fullname': event.published_by.get_full_name()})
|
||||
{'fullname': event.publication_confirmed_by.get_full_name()})
|
||||
text = unicode(event)
|
||||
text += u'\n'
|
||||
text += (ugettext(u'Bestätigt am: %(date)s') %
|
||||
{'date': event.published_at.strftime('%d.%m.%Y %H:%M:%S')})
|
||||
{'date': event.publication_confirmed_at.strftime('%d.%m.%Y %H:%M:%S')})
|
||||
else:
|
||||
event.set_published(user)
|
||||
event.confirm_publication(user)
|
||||
status = 'success'
|
||||
message = ugettext(u'Veröffentlichung registriert.')
|
||||
text = unicode(event)
|
||||
|
||||
Reference in New Issue
Block a user