X-Git-Url: https://git.mdrn.pl/prawokultury.git/blobdiff_plain/91117520dbe0336cd5acc91c6d8e23d81141f9df..b64d44fd01d504fbcbf3a180f9e620fed6d527ed:/shop/views.py?ds=inline diff --git a/shop/views.py b/shop/views.py index 16634e7..7c70f20 100644 --- a/shop/views.py +++ b/shop/views.py @@ -30,16 +30,16 @@ class OfferDetailView(FormView): self.object = get_object_or_404(Offer, **args) return super(OfferDetailView, self).dispatch(request, slug) + def get(self, *args, **kwargs): + return redirect(self.object.get_absolute_url()) + def get_context_data(self, *args, **kwargs): ctx = super(OfferDetailView, self).get_context_data(*args, **kwargs) ctx['entry'] = self.object.entry return ctx - def get_form(self, form_class): - if self.request.method == 'POST': - return form_class(self.object, self.request.POST) - else: - return form_class(self.object) + def get_form(self, form_class=OrderForm): + return form_class(self.object, self.request.POST) def form_valid(self, form): order = form.save() @@ -50,9 +50,11 @@ class OfferDetailView(FormView): return redirect(gateway_url_tuple[0]) -class ThanksView(TemplateView): +class ThanksView(DetailView): + model = Payment template_name = "shop/thanks.html" -class NoThanksView(TemplateView): +class NoThanksView(DetailView): + model = Payment template_name = "shop/no_thanks.html"