def form_valid(self, form): benefits_form = SponsorshiptBenefitsForm(data=self.benefits_data) if not benefits_form.is_valid(): return self._redirect_back_to_benefits() sponsor = form.save() uc = use_cases.CreateSponsorshipApplicationUseCase.build() sponsorship = uc.execute( self.request.user, sponsor, benefits_form.get_benefits(), benefits_form.get_package(), request=self.request, ) notified = uc.notifications[1].get_recipient_list({ "user": self.request.user, "sponsorship": sponsorship }) response = render( self.request, "sponsors/sponsorship_application_finished.html", context={ "sponsorship": sponsorship, "notified": notified }, ) cookies.delete_sponsorship_selected_benefits(response) return response
def form_valid(self, form): benefits_form = SponsorshiptBenefitsForm(data=self.benefits_data) if not benefits_form.is_valid(): return self._redirect_back_to_benefits() sponsor = form.save() Sponsorship.new(sponsor, benefits_form.get_benefits(), benefits_form.get_package()) response = super().form_valid(form) cookies.delete_sponsorship_selected_benefits(response) return response