Redirect on proposal get or form failure
This commit is contained in:
parent
9aff1e58d0
commit
ad76e78f05
1 changed files with 12 additions and 1 deletions
|
|
@ -71,10 +71,13 @@ class GovPlanDetailOGView(GovPlanDetailView):
|
|||
|
||||
|
||||
class GovPlanProposeUpdateView(GovernmentMixin, LoginRequiredMixin, UpdateView):
|
||||
template_name = "publicbody/add_proposal.html"
|
||||
slug_url_kwarg = "plan"
|
||||
form_class = GovernmentPlanUpdateProposalForm
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
return redirect(self.object)
|
||||
|
||||
def get_queryset(self):
|
||||
qs = GovernmentPlan.objects.filter(government=self.government)
|
||||
if self.request.user.is_authenticated and self.request.user.is_staff:
|
||||
|
|
@ -95,6 +98,14 @@ class GovPlanProposeUpdateView(GovernmentMixin, LoginRequiredMixin, UpdateView):
|
|||
)
|
||||
return redirect(self.object)
|
||||
|
||||
def form_invalid(self, form):
|
||||
messages.add_message(
|
||||
self.request,
|
||||
messages.ERROR,
|
||||
_("There's been an error with your form submission."),
|
||||
)
|
||||
return redirect(self.object)
|
||||
|
||||
|
||||
def search(request):
|
||||
q = request.GET.get("q", "")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue