Added OneClickAction for set published.

This commit is contained in:
2018-02-24 16:39:19 +01:00
parent 883d6f308a
commit 1751293fd1
3 changed files with 48 additions and 6 deletions

View File

@@ -134,6 +134,15 @@ class EventAcceptedMail(AbstractEventMail):
class EventToPublishMail(AbstractEventMail): class EventToPublishMail(AbstractEventMail):
_template_name = 'dav_events/emails/event_to_publish.txt' _template_name = 'dav_events/emails/event_to_publish.txt'
def __init__(self, set_published_action=None, *args, **kwargs):
self._set_published_action = set_published_action
super(EventToPublishMail, self).__init__(*args, **kwargs)
def _get_context_data(self, extra_context=None):
context = super(EventToPublishMail, self)._get_context_data(extra_context=extra_context)
context['set_published_url'] = self._set_published_action.get_absolute_url()
return context
def _get_subject(self, **kwargs): def _get_subject(self, **kwargs):
s = super(EventToPublishMail, self)._get_subject(**kwargs) s = super(EventToPublishMail, self)._get_subject(**kwargs)
s += u'Veranstaltung veröffentlichen' s += u'Veranstaltung veröffentlichen'

View File

@@ -227,7 +227,10 @@ class Event(models.Model):
publishers = get_users_by_role('publish_incremental') publishers = get_users_by_role('publish_incremental')
for user in publishers: for user in publishers:
email = emails.EventToPublishMail(recipient=user, event=self) 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.send() email.send()
email = emails.EventAcceptedMail(recipient=self.owner, event=self) email = emails.EventAcceptedMail(recipient=self.owner, event=self)
@@ -422,7 +425,7 @@ class Event(models.Model):
class OneClickAction(models.Model): class OneClickAction(models.Model):
COMMANDS = ( COMMANDS = (
('EA', 'accept event'), ('EA', 'accept event'),
('EP', 'mark event as published'), ('EP', 'report publishing of an event'),
('EL', 'login and go to event list') ('EL', 'login and go to event list')
) )
@@ -497,9 +500,37 @@ class OneClickAction(models.Model):
'text': text, 'text': text,
} }
elif self.command == 'EP': elif self.command == 'EP':
text = u''
try:
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:
status = 'info'
message = (ugettext(u'Veröffentlichung wurde bereits von %(fullname)s bestätigt.') %
{'fullname': event.published_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')})
else:
event.set_published(user)
status = 'success'
message = ugettext(u'Veröffentlichung registriert.')
text = unicode(event)
self.done = True
self.done_at = timezone.now()
self.save()
except Exception as e:
status = 'danger'
message = str(e)
logger.error('OneClickAction.run(): %s(%s): %s', self.command, self.parameters, message)
result['context'] = { result['context'] = {
'status': 'warning', 'status': status,
'message': ugettext(u'Funktion noch nicht verfügbar.'), 'message': message,
'text': text,
} }
elif self.command == 'EL': elif self.command == 'EL':
try: try:

View File

@@ -2,8 +2,10 @@
{{ trainer_firstname }} {{ trainer_familyname }} hat eine neue Veranstaltung angelegt. {{ trainer_firstname }} {{ trainer_familyname }} hat eine neue Veranstaltung angelegt.
Die Veranstaltung wurde zur Veröffentlichung frei gegeben. Die Veranstaltung wurde zur Veröffentlichung frei gegeben.
Über den folgenden Link könnt ihr die Veröffentlichung unmittelbar bestätigen:
{{ base_url }}{{ set_published_url }}
----- ----- Plain Text -----
{{ event.render_as_text }} {{ event.render_as_text }}
----- HTML Joomla ----- ----- HTML Joomla -----
@@ -52,4 +54,4 @@ Die Veranstaltung wurde zur Veröffentlichung frei gegeben.
{% endif %}{% if trainer_familyname %}<strong>{% trans 'Leitung' %}:</strong> {{ trainer_firstname }} {{ trainer_familyname }}{% if trainer_email or trainer_phone %} ({% if trainer_email %}<a href="mailto:{{ trainer_email }}">{{ trainer_email }}</a>{% endif %}{% if trainer_email and trainer_phone %}, {% endif %}{% if trainer_phone %} {{ trainer_phone }}{% endif %}){% endif %} {% endif %}{% if trainer_familyname %}<strong>{% trans 'Leitung' %}:</strong> {{ trainer_firstname }} {{ trainer_familyname }}{% if trainer_email or trainer_phone %} ({% if trainer_email %}<a href="mailto:{{ trainer_email }}">{{ trainer_email }}</a>{% endif %}{% if trainer_email and trainer_phone %}, {% endif %}{% if trainer_phone %} {{ trainer_phone }}{% endif %}){% endif %}
{% endif %}{% if registration_howto %} {% endif %}{% if registration_howto %}
<p>{{ registration_howto }}</p> <p>{{ registration_howto }}</p>
{% endif %} {% endif %}