X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/003b3eecdce065c16cf0e3af23763ae735d4e4ef..55d94d75dff5d3a30dd0cce7554e68d23627376d:/src/club/views.py diff --git a/src/club/views.py b/src/club/views.py index b2657e62f..a55f28481 100644 --- a/src/club/views.py +++ b/src/club/views.py @@ -4,7 +4,7 @@ from django.conf import settings from django.contrib.auth.decorators import login_required, permission_required from django.db.models import Sum -from django.http import HttpResponse, HttpResponseRedirect +from django.http import HttpResponse, HttpResponseRedirect, JsonResponse from django.shortcuts import get_object_or_404, render from django.urls import reverse from django.utils.decorators import method_decorator @@ -59,6 +59,17 @@ class DonationStep2(UpdateView): 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, + }) + + class JoinView(CreateView): form_class = forms.DonationStep1Form template_name = 'club/donation_step1.html'