+
+@method_decorator(never_cache, name='dispatch')
+class DonationStep1(UpdateView):
+ queryset = models.Schedule.objects.filter(payed_at=None)
+ form_class = forms.DonationStep1Form
+ slug_field = slug_url_kwarg = 'key'
+ template_name = 'club/donation_step1.html'
+ step = 1
+
+ def get_context_data(self, **kwargs):
+ c = super().get_context_data(**kwargs)
+ c['club'] = models.Club.objects.first()
+ return c
+
+ def get_success_url(self):
+ return reverse('donation_step2', args=[self.object.key])
+
+
+@method_decorator(never_cache, name='dispatch')
+class DonationStep2(UpdateView):
+ queryset = models.Schedule.objects.filter(payed_at=None)
+ form_class = forms.DonationStep2Form
+ slug_field = slug_url_kwarg = 'key'
+ template_name = 'club/donation_step2.html'
+ step = 2
+
+ def get_context_data(self, **kwargs):
+ c = super().get_context_data(**kwargs)
+ c['club'] = models.Club.objects.first()
+ return c
+
+
+def set_monthly(request, key):
+ schedule = get_object_or_404(models.Schedule, payed_at=None, key=key)
+ if request.POST:
+ schedule.monthly = True
+ schedule.save(update_fields=['monthly'])
+ return JsonResponse({
+ "amount": schedule.amount,
+ "monthly": schedule.monthly,
+ })
+
+