-# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
-# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+# This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
#
from django.conf import settings
from django.contrib.auth.decorators import login_required, permission_required
from django.views import View
from .payu import POSS
from .payu import views as payu_views
-from .forms import ScheduleForm, PayUCardTokenForm
+from .forms import PayUCardTokenForm
from . import forms
from . import models
from .helpers import get_active_schedule
queryset = models.Schedule.objects.filter(payed_at=None)
form_class = forms.DonationStep1Form
slug_field = slug_url_kwarg = 'key'
- template_name = 'club/2022/donation_step1.html'
+ template_name = 'club/donation_step1.html'
step = 1
def get_context_data(self, **kwargs):
queryset = models.Schedule.objects.filter(payed_at=None)
form_class = forms.DonationStep2Form
slug_field = slug_url_kwarg = 'key'
- template_name = 'club/2022/donation_step2.html'
+ 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
+
class JoinView(CreateView):
+ form_class = forms.DonationStep1Form
+ template_name = 'club/donation_step1.html'
+
@property
def club(self):
return models.Club.objects.first()
- @property
- def new_layout(self):
- return self.request.EXPERIMENTS['layout'].value
-
- def get_template_names(self):
- if self.new_layout:
- return 'club/2022/donation_step1.html'
- return 'club/membership_form.html'
-
- def get_form_class(self):
- if self.new_layout:
- return forms.DonationStep1Form
- return ScheduleForm
-
def is_app(self):
return self.request.GET.get('app')
return c
def get_initial(self):
+ # referer?
if self.request.user.is_authenticated and self.request.user.email:
return {
'email': self.request.user.email
def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
- if not self.new_layout:
- kwargs['referer'] = self.request.META.get('HTTP_REFERER', '')
+ #kwargs['referer'] = self.request.META.get('HTTP_REFERER', '')
return kwargs
def form_valid(self, form):
return retval
def get_success_url(self):
- if self.new_layout:
- return reverse('donation_step2', args=[self.object.key])
- return self.object.initiate_payment(self.request)
+ return reverse('donation_step2', args=[self.object.key])
@method_decorator(never_cache, name='dispatch')
step = 3
def get_template_names(self):
- if self.request.EXPERIMENTS['layout'].value:
- if not self.object.payed_at:
- return 'club/2022/donation_step3.html'
+ if not self.object.payed_at:
+ return 'club/donation_step3.html'
return 'club/schedule.html'
def get_context_data(self, *args, **kwargs):
return HttpResponseRedirect(schedule.get_absolute_url())
-class DummyPaymentView(TemplateView):
- template_name = 'club/dummy_payment.html'
-
- def get_context_data(self, key):
- return {
- 'schedule': models.Schedule.objects.get(key=key),
- }
-
- def post(self, request, key):
- schedule = models.Schedule.objects.get(key=key)
- schedule.create_payment()
-
- return HttpResponseRedirect(schedule.get_absolute_url())
-
-
class PayUPayment(DetailView):
model = models.Schedule
slug_field = slug_url_kwarg = 'key'
class ScheduleThanksView(DetailView):
model = models.Schedule
+ template_name = 'club/donation_step4.html'
slug_field = slug_url_kwarg = 'key'
step = 4
- def get_template_names(self):
- if self.request.EXPERIMENTS['layout'].value:
- return 'club/2022/donation_step4.html'
- return 'club/thanks.html'
-
def get_context_data(self, *args, **kwargs):
ctx = super().get_context_data(*args, **kwargs)
ctx['active_menu_item'] = 'club'