UPD: dav_events: enable save as draft
All checks were successful
buildbot/tox Build done.

This commit is contained in:
2020-12-18 14:30:17 +01:00
parent cbc3df97c1
commit 1f674125ec
3 changed files with 29 additions and 6 deletions

View File

@@ -40,11 +40,9 @@
{% bootstrap_icon 'remove' %}  {% bootstrap_icon 'remove' %} 
{% trans 'Abbrechen' %} {% trans 'Abbrechen' %}
</a> </a>
<!--
<button id="btn-form-save" type="submit" name="save" class="btn btn-info"> <button id="btn-form-save" type="submit" name="save" class="btn btn-info">
{% bootstrap_icon 'hdd' %}&thinsp; {% bootstrap_icon 'hdd' %}&thinsp;
{% trans 'Als Entwurf speichern' %} {% trans 'Als Entwurf speichern' %}
</button> </button>
-->
{% endbuttons %} {% endbuttons %}
{% endblock form-buttons %} {% endblock form-buttons %}

View File

@@ -543,6 +543,18 @@ class EventUpdateStatusView(EventPermissionMixin, generic.DetailView):
messages.error(request, message) messages.error(request, message)
return HttpResponseRedirect(event.get_absolute_url()) return HttpResponseRedirect(event.get_absolute_url())
if not event.workflow.has_reached_status('publishing*') and not event.workflow.has_reached_status('published*'):
cur_pub_date = event.planned_publication_date
real_pub_date, real_pub_issue = event.workflow.plan_publication(event.first_day, event.deadline)
if cur_pub_date != real_pub_date:
if real_pub_date is None:
real_pub_str = _(u'Unverzüglich')
else:
real_pub_str = u'%s (%s)' % (real_pub_date.strftime('%d.%m.%Y'), real_pub_issue)
event.planned_publication_date = real_pub_date
event.save()
messages.warning(request, _(u'Veröffentlichungsdatum wurde angepasst: %s') % real_pub_str)
event.workflow.update_status(status, request.user) event.workflow.update_status(status, request.user)
if status.startswith('submit'): if status.startswith('submit'):
@@ -602,7 +614,21 @@ class EventUpdateView(EventPermissionMixin, generic.UpdateView):
def form_valid(self, form): def form_valid(self, form):
form.instance.editor = self.request.user form.instance.editor = self.request.user
self.object = form.save() event = form.save()
self.object = event
if not event.workflow.has_reached_status('publishing*') and not event.workflow.has_reached_status('published*'):
cur_pub_date = event.planned_publication_date
real_pub_date, real_pub_issue = event.workflow.plan_publication(event.first_day, event.deadline)
if cur_pub_date != real_pub_date:
if real_pub_date is None:
real_pub_str = _(u'Unverzüglich')
else:
real_pub_str = u'%s (%s)' % (real_pub_date.strftime('%d.%m.%Y'), real_pub_issue)
event.planned_publication_date = real_pub_date
event.save()
messages.warning(self.request, _(u'Veröffentlichungsdatum wurde angepasst: %s') % real_pub_str)
return HttpResponseRedirect(self.get_success_url()) return HttpResponseRedirect(self.get_success_url())
@method_decorator(login_required) @method_decorator(login_required)

View File

@@ -489,9 +489,8 @@ class BasicWorkflow(object):
# #
# Misc logic # Misc logic
# #
# TODO: is a class method a good idea? @staticmethod
@classmethod def plan_publication(first_day, deadline=None):
def plan_publication(cls, first_day, deadline=None):
app_config = apps.get_containing_app_config(__package__) app_config = apps.get_containing_app_config(__package__)
if deadline: if deadline: