Skip to content
Snippets Groups Projects
Commit 50318ee2 authored by Nadja Geisler's avatar Nadja Geisler :sunny:
Browse files

Merge branch 'improve-submission-coupling' into 'main'

Introduce detail and edit URLs as properties in AK model

Closes #166

See merge request !161
parents 32b2471c a867f11c
No related branches found
No related tags found
No related merge requests found
...@@ -199,7 +199,7 @@ class AKAndAKWishSubmissionView(EventSlugMixin, EventInactiveRedirectMixin, Crea ...@@ -199,7 +199,7 @@ class AKAndAKWishSubmissionView(EventSlugMixin, EventInactiveRedirectMixin, Crea
def get_success_url(self): def get_success_url(self):
messages.add_message(self.request, messages.SUCCESS, _("AK successfully created")) messages.add_message(self.request, messages.SUCCESS, _("AK successfully created"))
return reverse_lazy('submit:ak_detail', kwargs={'event_slug': self.kwargs['event_slug'], 'pk': self.object.pk}) return self.object.detail_url
def form_valid(self, form): def form_valid(self, form):
if not form.cleaned_data["event"].active: if not form.cleaned_data["event"].active:
...@@ -249,7 +249,7 @@ class AKEditView(EventSlugMixin, EventInactiveRedirectMixin, UpdateView): ...@@ -249,7 +249,7 @@ class AKEditView(EventSlugMixin, EventInactiveRedirectMixin, UpdateView):
def get_success_url(self): def get_success_url(self):
messages.add_message(self.request, messages.SUCCESS, _("AK successfully updated")) messages.add_message(self.request, messages.SUCCESS, _("AK successfully updated"))
return reverse_lazy('submit:ak_detail', kwargs={'event_slug': self.kwargs['event_slug'], 'pk': self.object.pk}) return self.object.detail_url
def form_valid(self, form): def form_valid(self, form):
if not form.cleaned_data["event"].active: if not form.cleaned_data["event"].active:
...@@ -287,7 +287,7 @@ class AKOwnerCreateView(EventSlugMixin, EventInactiveRedirectMixin, CreateView): ...@@ -287,7 +287,7 @@ class AKOwnerCreateView(EventSlugMixin, EventInactiveRedirectMixin, CreateView):
ak.owners.add(self.object) ak.owners.add(self.object)
messages.add_message(self.request, messages.SUCCESS, messages.add_message(self.request, messages.SUCCESS,
_("Added '{owner}' as new owner of '{ak.name}'").format(owner=self.object, ak=ak)) _("Added '{owner}' as new owner of '{ak.name}'").format(owner=self.object, ak=ak))
return reverse_lazy('submit:ak_detail', kwargs={'event_slug': self.kwargs['event_slug'], 'pk': ak.pk}) return ak.detail_url
return reverse_lazy('submit:submit_ak', return reverse_lazy('submit:submit_ak',
kwargs={'event_slug': self.kwargs['event_slug'], 'owner_slug': self.object.slug}) kwargs={'event_slug': self.kwargs['event_slug'], 'owner_slug': self.object.slug})
...@@ -375,8 +375,7 @@ class AKSlotAddView(EventSlugMixin, EventInactiveRedirectMixin, CreateView): ...@@ -375,8 +375,7 @@ class AKSlotAddView(EventSlugMixin, EventInactiveRedirectMixin, CreateView):
def get_success_url(self): def get_success_url(self):
messages.add_message(self.request, messages.SUCCESS, _("AK Slot successfully added")) messages.add_message(self.request, messages.SUCCESS, _("AK Slot successfully added"))
return reverse_lazy('submit:ak_detail', return self.object.ak.detail_url
kwargs={'event_slug': self.kwargs['event_slug'], 'pk': self.object.ak.pk})
class AKSlotEditView(EventSlugMixin, EventInactiveRedirectMixin, UpdateView): class AKSlotEditView(EventSlugMixin, EventInactiveRedirectMixin, UpdateView):
...@@ -389,7 +388,7 @@ class AKSlotEditView(EventSlugMixin, EventInactiveRedirectMixin, UpdateView): ...@@ -389,7 +388,7 @@ class AKSlotEditView(EventSlugMixin, EventInactiveRedirectMixin, UpdateView):
if akslot.start is not None: if akslot.start is not None:
messages.add_message(self.request, messages.WARNING, messages.add_message(self.request, messages.WARNING,
_("You cannot edit a slot that has already been scheduled")) _("You cannot edit a slot that has already been scheduled"))
return redirect('submit:ak_detail', event_slug=self.kwargs['event_slug'], pk=akslot.ak.pk) return HttpResponseRedirect(akslot.ak.detail_url)
return super().get(request, *args, **kwargs) return super().get(request, *args, **kwargs)
def get_context_data(self, *, object_list=None, **kwargs): def get_context_data(self, *, object_list=None, **kwargs):
...@@ -399,8 +398,7 @@ class AKSlotEditView(EventSlugMixin, EventInactiveRedirectMixin, UpdateView): ...@@ -399,8 +398,7 @@ class AKSlotEditView(EventSlugMixin, EventInactiveRedirectMixin, UpdateView):
def get_success_url(self): def get_success_url(self):
messages.add_message(self.request, messages.SUCCESS, _("AK Slot successfully updated")) messages.add_message(self.request, messages.SUCCESS, _("AK Slot successfully updated"))
return reverse_lazy('submit:ak_detail', return self.object.ak.detail_url
kwargs={'event_slug': self.kwargs['event_slug'], 'pk': self.object.ak.pk})
class AKSlotDeleteView(EventSlugMixin, EventInactiveRedirectMixin, DeleteView): class AKSlotDeleteView(EventSlugMixin, EventInactiveRedirectMixin, DeleteView):
...@@ -412,7 +410,7 @@ class AKSlotDeleteView(EventSlugMixin, EventInactiveRedirectMixin, DeleteView): ...@@ -412,7 +410,7 @@ class AKSlotDeleteView(EventSlugMixin, EventInactiveRedirectMixin, DeleteView):
if akslot.start is not None: if akslot.start is not None:
messages.add_message(self.request, messages.WARNING, messages.add_message(self.request, messages.WARNING,
_("You cannot delete a slot that has already been scheduled")) _("You cannot delete a slot that has already been scheduled"))
return redirect('submit:ak_detail', event_slug=self.kwargs['event_slug'], pk=akslot.ak.pk) return HttpResponseRedirect(akslot.ak.detail_url)
return super().get(request, *args, **kwargs) return super().get(request, *args, **kwargs)
def get_context_data(self, *, object_list=None, **kwargs): def get_context_data(self, *, object_list=None, **kwargs):
...@@ -422,8 +420,7 @@ class AKSlotDeleteView(EventSlugMixin, EventInactiveRedirectMixin, DeleteView): ...@@ -422,8 +420,7 @@ class AKSlotDeleteView(EventSlugMixin, EventInactiveRedirectMixin, DeleteView):
def get_success_url(self): def get_success_url(self):
messages.add_message(self.request, messages.SUCCESS, _("AK Slot successfully deleted")) messages.add_message(self.request, messages.SUCCESS, _("AK Slot successfully deleted"))
return reverse_lazy('submit:ak_detail', return self.object.ak.detail_url
kwargs={'event_slug': self.kwargs['event_slug'], 'pk': self.object.ak.pk})
class AKAddOrgaMessageView(EventSlugMixin, CreateView): class AKAddOrgaMessageView(EventSlugMixin, CreateView):
...@@ -444,5 +441,4 @@ class AKAddOrgaMessageView(EventSlugMixin, CreateView): ...@@ -444,5 +441,4 @@ class AKAddOrgaMessageView(EventSlugMixin, CreateView):
def get_success_url(self): def get_success_url(self):
messages.add_message(self.request, messages.SUCCESS, _("Message to organizers successfully saved")) messages.add_message(self.request, messages.SUCCESS, _("Message to organizers successfully saved"))
return reverse_lazy('submit:ak_detail', return self.object.ak.detail_url
kwargs={'event_slug': self.kwargs['event_slug'], 'pk': self.object.ak.pk})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment