--- /dev/null
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.20 on 2019-04-17 13:39
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('club', '0007_auto_20190416_1625'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='membership',
+ name='name',
+ field=models.CharField(blank=True, max_length=255),
+ ),
+ ]
""" Represents a user being recognized as a member of the club. """
user = models.OneToOneField(settings.AUTH_USER_MODEL, verbose_name=_('user'), on_delete=models.CASCADE)
created_at = models.DateTimeField(_('created at'), auto_now_add=True)
+ name = models.CharField(max_length=255, blank=True)
honorary = models.BooleanField(default=False)
class Meta:
def status_updated(self):
if self.status == 'COMPLETED':
- new_exp = self.schedule.plan.get_next_installment(now())
+ since = self.schedule.expires_at or now()
+ new_exp = self.schedule.plan.get_next_installment(since)
if self.schedule.expires_at is None or self.schedule.expires_at < new_exp:
self.schedule.expires_at = new_exp
self.schedule.save()
<h1>Plan płatności</h1>
-<div>{{ schedule.email }}</div>
-<div>{{ schedule.amount }}</div>
-<div>{{ schedule.plan.get_interval_display }}</div>
-
-<div>{{ schedule.is_active|yesno:"Aktywne,Nieaktywne" }}</div>
+<div>E-mail: {{ schedule.email }}</div>
+<div>Składka: {{ schedule.amount }} zł {{ schedule.plan.get_interval_display }}</div>
+<div>Wybrana metoda płatności: {{ schedule.get_payment_method.name }}</div>
+
+{% if schedule.is_active %}
+ {% if schedule.plan.is_perpetual %}
+ Opłacona na zawsze.
+ {% endif %}
+ Aktualnie opłacona do: {{ schedule.expires_at }}
+
+ {% if schedule.get_payment_method.is_recurring %}
+ <form method='post' action="{% url 'club_cancel' schedule.key %}">
+ {% csrf_token %}
+ <button type="submit">Anuluj kolejną płatność</button>
+ </form>
+ {% else %}
+ <form method='post' action=''>
+ {% csrf_token %}
+ <button type="submit">Opłać kolejny okres</button>
+ </form>
+ {% endif %}
-<div>Start: {{ schedule.started_at }}</div>
-<div>Opłacone do: {{ schedule.expires_at|default:"brak" }} {% if schedule.is_cancelled %}(anulowana){% endif %}</div>
-{% if schedule.expires_at and not schedule.is_cancelled %}
-<form method='post' action="{% url 'club_cancel' schedule.key %}">
- {% csrf_token %}
- <button type="submit">Anuluj płatność</button>
-</form>
+{% else %}
+ {% if schedule.is_expired %}
+ Członkostwo wygasło.
+ <form method='post' action=''>
+ {% csrf_token %}
+ <button type="submit">Opłać kolejny okres</button>
+ </form>
+
+
+ {% else %}
+ Składka nie została jeszcze opłacona.
+ {% if schedule.payuorder_set.exists %}
+ Czekamy na potwierdzenie płatności.
+ {% else %}
+
+ <form method='post' action=''>
+ {% csrf_token %}
+ <button type="submit">Zapłać składkę</button>
+ </form>
+
+ {% endif %}
+ {% endif %}
{% endif %}
-{% if schedule.is_expired %}
- Płatność wygasła. <a href="{% url 'club_join' %}">Wykonaj nową płatność</a>.
-{% endif %}
+<hr>
+
+
{% if schedule.membership %}
<p>
Członek/członkini Towarzystwa nr {{ schedule.membership.id }} ({{ schedule.membership.user }}).
</p>
+
+ <form method='post' action='{% url "club_membership" %}'>
+ {% csrf_token %}
+ Imię i nazwisko na legitymację: <br>
+ <input name="name" value="{{ schedule.membership.name|default:schedule.membership.user.username }}"><br>
+ <button type="submit">Zapisz</button>
+ </form>
+
{% else %}
<p>
Płatność nie przypisana do członkostwa.<br>
url(r'notify/(?P<pk>\d+)/', views.PayUNotifyView.as_view(), name='club_payu_notify'),
+ url(r'czlonek/', views.MembershipView.as_view(), name='club_membership'),
]
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
-from django.views.generic import FormView, CreateView, TemplateView, DetailView
+from django.views.generic import FormView, CreateView, TemplateView, DetailView, UpdateView
from django.views import View
from .payu import POSS
from .payu import views as payu_views
def post(self, request, key):
schedule = self.get_object()
- if not schedule.is_active():
- return HttpResponseRedirect(schedule.initiate_payment(request))
- else:
- return HttpResponseRedirect(schedule.get_absolute_url())
+ return HttpResponseRedirect(schedule.initiate_payment(request))
@login_required
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
url(r'^newsletter/', include('newsletter.urls')),
url(r'^formularz/', include('contact.urls')),
url(r'^isbn/', include('isbn.urls')),
+
+ url(r'^paypal/app-form/$', RedirectView.as_view(
+ url='/towarzystwo/dolacz/?app=1', permanent=True)),
+
url(r'^paypal/', include('paypal.urls')),
url(r'^powiadomienie/', include('push.urls')),
url(r'^towarzystwo/', include('club.urls')),