Skip to content
Snippets Groups Projects
Commit caa1fc47 authored by Benjamin Hättasch's avatar Benjamin Hättasch
Browse files

Improve history handling

Only store AK in database once all attributes are correctly set.
Previously, each AK was automatically edited directly after saving to add the link, which created two history entries for that AK.
This resolves #141.
Additionally, only display slots as (re-)scheduled when they are indeed scheduled (i.e., have a starting time stamp).
parent ec4a6889
No related branches found
No related tags found
No related merge requests found
...@@ -54,7 +54,7 @@ class DashboardEventView(DetailView): ...@@ -54,7 +54,7 @@ class DashboardEventView(DetailView):
# Changes in plan # Changes in plan
if apps.is_installed("AKPlan"): if apps.is_installed("AKPlan"):
if not context['event'].plan_hidden: if not context['event'].plan_hidden:
last_changed_slots = AKSlot.objects.filter(event=context['event']).order_by('-updated')[ last_changed_slots = AKSlot.objects.filter(event=context['event'], start__isnull=False).order_by('-updated')[
:int(settings.DASHBOARD_RECENT_MAX)] :int(settings.DASHBOARD_RECENT_MAX)]
for changed_slot in last_changed_slots: for changed_slot in last_changed_slots:
recent_changes.append({'icon': ('clock', 'far'), recent_changes.append({'icon': ('clock', 'far'),
......
...@@ -215,7 +215,8 @@ class AKAndAKWishSubmissionView(EventSlugMixin, EventInactiveRedirectMixin, Crea ...@@ -215,7 +215,8 @@ class AKAndAKWishSubmissionView(EventSlugMixin, EventInactiveRedirectMixin, Crea
return redirect(reverse_lazy('submit:submission_overview', return redirect(reverse_lazy('submit:submission_overview',
kwargs={'event_slug': form.cleaned_data["event"].slug})) kwargs={'event_slug': form.cleaned_data["event"].slug}))
super_form_valid = super().form_valid(form) # Generate object but don't store it in the database yet
self.object = form.save(commit=False)
# Generate wiki link # Generate wiki link
if form.cleaned_data["event"].base_url: if form.cleaned_data["event"].base_url:
...@@ -225,7 +226,9 @@ class AKAndAKWishSubmissionView(EventSlugMixin, EventInactiveRedirectMixin, Crea ...@@ -225,7 +226,9 @@ class AKAndAKWishSubmissionView(EventSlugMixin, EventInactiveRedirectMixin, Crea
if len(link) > 200: if len(link) > 200:
messages.add_message(self.request, messages.WARNING, messages.add_message(self.request, messages.WARNING,
_("Due to technical reasons, the link you entered was truncated to a length of 200 characters")) _("Due to technical reasons, the link you entered was truncated to a length of 200 characters"))
self.object.save()
# Try to save AK and get redirect URL
super_form_valid = super().form_valid(form)
# Set tags (and generate them if necessary) # Set tags (and generate them if necessary)
for tag_name in form.cleaned_data["tag_names"]: for tag_name in form.cleaned_data["tag_names"]:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment