From df783168c60a1a0ad1681827624c60596650a1cb Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Sun, 20 May 2018 21:54:36 +0200 Subject: [PATCH] filter speakerproposals by user, and redirect directly to combined submit view if no existing speakerproposals was found --- src/program/views.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/program/views.py b/src/program/views.py index 52a8ee39..8862f421 100644 --- a/src/program/views.py +++ b/src/program/views.py @@ -413,6 +413,10 @@ class CombinedProposalPersonSelectView(LoginRequiredMixin, CampViewMixin, ListVi return super().dispatch(request, *args, **kwargs) + def get_queryset(self, **kwargs): + # only show speaker proposals for the current user + return super().get_queryset().filter(user=self.request.user) + def get_context_data(self, **kwargs): """ Add EventType to template context @@ -421,6 +425,12 @@ class CombinedProposalPersonSelectView(LoginRequiredMixin, CampViewMixin, ListVi context['eventtype'] = self.eventtype return context + def get(self, request, *args, **kwargs): + """ If we don't have any existing SpeakerProposals just redirect directly to the combined submit view """ + if not self.get_queryset().exists(): + return redirect(reverse_lazy('program:proposal_combined_submit', kwargs={'camp_slug': self.camp.slug, 'event_type_slug': self.eventtype.slug})) + return super().get(request, *args, **kwargs) + class CombinedProposalSubmitView(LoginRequiredMixin, CampViewMixin, CreateView): """