+
+
+class PayUPayment(DetailView):
+ model = models.Schedule
+ slug_field = slug_url_kwarg = 'key'
+
+ def get(self, request, key):
+ schedule = self.get_object()
+ return HttpResponseRedirect(schedule.initiate_payment(request))
+
+
+
+class PayURecPayment(payu_views.RecPayment):
+ form_class = PayUCardTokenForm
+
+ def get_schedule(self):
+ return get_object_or_404(models.Schedule, key=self.kwargs['key'])
+
+ def get_pos(self):
+ pos_id = recurring_payment_method.pos_id
+ return POSS[pos_id]
+
+ def get_success_url(self):
+ return self.get_schedule().pay(self.request)
+
+
+class PayUNotifyView(payu_views.NotifyView):
+ order_model = models.PayUOrder
+
+
+class MembershipView(UpdateView):
+ fields = ['name']
+
+ def get_success_url(self):
+ # TODO: get only current schedule if multiple.
+ return self.object.schedule_set.first().get_absolute_url()
+
+ def get_object(self):
+ return self.request.user.membership
+
+
+class ScheduleThanksView(DetailView):
+ model = models.Schedule
+ slug_field = slug_url_kwarg = 'key'
+ template_name = 'club/thanks.html'
+
+ def get_context_data(self, *args, **kwargs):
+ ctx = super().get_context_data(*args, **kwargs)
+ ctx['active_menu_item'] = 'club'
+ return ctx
+
+
+class YearSummaryView(DetailView):
+ model = models.Schedule
+ slug_field = slug_url_kwarg = 'key'
+ template_name = 'club/year_summary.html'
+
+ def get_context_data(self, *args, **kwargs):
+ ctx = super().get_context_data(*args, **kwargs)
+ ctx['payments'] = models.PayUOrder.objects.filter(
+ status='COMPLETED',
+ completed_at__year=self.kwargs['year'],
+ schedule__email=self.object.email,
+ ).order_by('completed_at')
+ ctx['total_amount'] = ctx['payments'].aggregate(s=Sum('schedule__amount'))['s']
+ return ctx