#
import json
from django.http import Http404, HttpResponse
+from django.utils.decorators import method_decorator
+from django.views.decorators.cache import never_cache
from rest_framework.generics import ListAPIView, RetrieveAPIView, get_object_or_404
from rest_framework.permissions import DjangoModelPermissionsOrAnonReadOnly
from rest_framework.response import Response
lookup_field = 'slug'
permission_classes = [IsClubMember]
+ @method_decorator(never_cache)
def get(self, *args, **kwargs):
return HttpResponse(self.get_object().get_media('epub'))
</li>
</ul>
{% else %}
- <p class="book-box-tools">{% trans "For now this work is only available for our subscribers." %}</p>
+ <p class="book-box-tools">{% trans "For now this work is only available for our subscribers." %}
+ <a href="/towarzystwo/">Dołącz do Towarzystwa Przyjaciół Wolnych Lektur</a>
+ </p>
{% endif %}
{% endcache %}
{% block book-box-extra-info %}{% endblock %}
{% endwith %}
{% block right-column %}
- {% if audiobooks %}
+ {% if audiobooks %}{% if book|status:request.user != 'closed' %}
<div class="book-right-column">
{% include 'catalogue/snippets/jplayer.html' %}
</div>
- {% endif %}
+ {% endif %}{% endif %}
{% endblock %}
{% if book.abstract %}
<div class="abstract more-expand">
-{% load i18n %}
-{% if audiobooks %}
+{% load i18n catalogue_tags %}
+{% if audiobooks %}{% if book|status:request.user != 'closed' %}
<div class="jp-type-playlist">
<div id="jplayer" class="jp-jplayer" data-player="jp_container_{{ book.pk }}"
data-supplied="oga,mp3"></div>
{% endif %}
</div>
</div>
-{% endif %}
+{% endif %}{% endif %}
from django.utils.http import urlquote_plus
from django.utils import translation
from django.utils.translation import ugettext as _, ugettext_lazy
+from django.views.decorators.cache import never_cache
from ajaxable.utils import AjaxableFormView
from club.models import Membership
return HttpResponse(tag.description)
+@never_cache
def embargo_link(request, format_, slug):
book = get_object_or_404(Book, slug=slug)
if format_ not in Book.formats:
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-03-04 11:36+0100\n"
-"PO-Revision-Date: 2019-03-04 11:34+0100\n"
+"PO-Revision-Date: 2019-06-17 15:08+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: pl\n"
#: models.py:26
msgid "a year"
-msgstr "rocznie"
+msgstr "raz do roku"
#: models.py:27
msgid "in perpetuity"
-msgstr "na zawsze"
+msgstr "raz na zawsze"
#: models.py:30
msgid "inteval"
--- /dev/null
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.20 on 2019-05-29 07:46
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('club', '0009_auto_20190510_1510'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='schedule',
+ name='email_sent',
+ field=models.BooleanField(default=False),
+ ),
+ migrations.AlterField(
+ model_name='schedule',
+ name='method',
+ field=models.CharField(choices=[('payu', 'PayU'), ('payu-re', 'PayU (płatność odnawialna)')], max_length=255, verbose_name='method'),
+ ),
+ ]
from datetime import datetime, timedelta
from django.conf import settings
from django.contrib.sites.models import Site
+from django.core.mail import send_mail
from django.urls import reverse
from django.db import models
+from django import template
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _, ungettext, ugettext, get_language
from catalogue.utils import get_random_hash
is_cancelled = models.BooleanField(_('cancelled'), default=False)
started_at = models.DateTimeField(_('started at'), auto_now_add=True)
expires_at = models.DateTimeField(_('expires_at'), null=True, blank=True)
+ email_sent = models.BooleanField(default=False)
class Meta:
verbose_name = _('schedule')
def get_absolute_url(self):
return reverse('club_schedule', args=[self.key])
+ def get_thanks_url(self):
+ return reverse('club_thanks', args=[self.key])
+
def get_payment_method(self):
return method_by_slug[self.method]
def is_active(self):
return self.expires_at is not None and self.expires_at > now()
+ def send_email(self):
+ ctx = {'schedule': self}
+ send_mail(
+ template.loader.render_to_string('club/email/thanks_subject.txt', ctx).strip(),
+ template.loader.render_to_string('club/email/thanks.txt', ctx),
+ settings.CONTACT_EMAIL, [self.email], fail_silently=False)
+ self.email_sent = True
+ self.save()
+
class Membership(models.Model):
""" Represents a user being recognized as a member of the club. """
def get_continue_url(self):
return "https://{}{}".format(
Site.objects.get_current().domain,
- self.schedule.get_absolute_url())
+ self.schedule.get_thanks_url())
def get_description(self):
return ugettext('Towarzystwo Wolnych Lektur')
self.schedule.expires_at = new_exp
self.schedule.save()
+ if not self.schedule.email_sent:
+ self.schedule.send_email()
+
class PayUCardToken(payu_models.CardToken):
schedule = models.ForeignKey(Schedule, on_delete=models.CASCADE)
class PayURe(PaymentMethod):
slug='payu-re'
- name = 'PayU Recurring'
+ name = 'PayU (płatność odnawialna)'
template_name = 'club/payment/payu-re.html'
is_recurring = True
class PayPal(PaymentMethod):
slug='paypal'
- name = 'PayPal'
+ name = 'PayPal (płatność odnawialna)'
template_name = 'club/payment/paypal.html'
is_recurring = True
is_onetime = True
methods = []
-pos = getattr(settings, 'CLUB_PAYU_POS', None)
-if pos:
- payu_method = PayU(pos)
- methods.append(payu_method)
-else:
- payu_method = None
-
pos= getattr(settings, 'CLUB_PAYU_RECURRING_POS', None)
if pos:
payure_method = PayURe(pos)
else:
payure_method = None
+pos = getattr(settings, 'CLUB_PAYU_POS', None)
+if pos:
+ payu_method = PayU(pos)
+ methods.append(payu_method)
+else:
+ payu_method = None
+
-methods.append(PayPal())
+#methods.append(PayPal())
method_by_slug = {
self.save()
- return response.get('redirectUri', self.schedule.get_absolute_url())
+ return response.get('redirectUri', self.schedule.get_thanks_url())
class Notification(models.Model):
--- /dev/null
+{% load chunks %}{% chunk "club_email_thanks" %}
+
+Od {{ schedule.started_at.date }} wspierasz nas kwotą {{ schedule.amount }} zł {{ schedule.plan.get_interval_display }}.
+
+{% if schedule.membership %}
+{% chunk "club_email_thanks_registered" %}
+{% else %}
+{% chunk "club_email_thanks_unregistered" %}
+
+https://wolnelektury.pl{{ schedule.get_absolute_url }}
+{% endif %}
+
+{% chunk "club_email_thanks_bottom" %}
--- /dev/null
+{% load chunks %}{% chunk "club_email_thanks_subject" %}
{% extends "base/base.html" %}
{% load active_schedule from club %}
+{% load chunks %}
-{% block titleextra %}Towarzystwo Wolnych Lektur{% endblock %}
+{% block titleextra %}Towarzystwo Przyjaciół Wolnych Lektur{% endblock %}
{% block body %}
<div class="white-box normal-text">
- <h1>Towarzystwo Wolnych Lektur</h1>
+ <h1>Towarzystwo Przyjaciół Wolnych Lektur</h1>
<p>Towarzystwo jest fajne.</p>
+ {% chunk 'club' %}
+
+<p style="margin-top: 2em;">
{% with schedule=request.user|active_schedule %}
{% if schedule %}
-<p><a href="{{ schedule.get_absolute_url }}">Jesteś już w Towarzystwie</a>!</p>
+<a href="{{ schedule.get_absolute_url }}">Gratulacje – należysz już do Towarzystwa Przyjaciół Wolnych Lektur!</a></p>
{% else %}
-<a href="{% url 'club_join' %}">Dołącz do Towarzystwa</a>.
+<a style="background:#018189;color:white;border-radius: 10px;padding:1em 2em" href="{% url 'club_join' %}">Dołącz do Towarzystwa</a></p>
{% endif %}
{% endwith %}
{% extends request.session.from_app|yesno:"base/app.html,base/base.html" %}
+{% load chunks %}
{% block titleextra %}Towarzystwo Wolnych Lektur{% endblock %}
<div class="white-box normal-text">
- <h1>{% if membership %}Odnów swoje członkostwo w Towarzystwie Wolnych Lektur{% else %}Dołącz do Towarzystwa Wolnych Lektur{% endif %}</h1>
+ <h1>{% if membership %}Odnów swoje członkostwo w Towarzystwie Przyjaciół Wolnych Lektur{% else %}Dołącz do Towarzystwa Przyjaciół Wolnych Lektur{% endif %}</h1>
+
+{% chunk 'club_form_top' %}
<form method="POST" action="" id="payment-form" class="wlform">
{% csrf_token %}
- <h2>Składka</h2>
-
+ <h2>Zadeklaruj, jak często i jaką kwotą chcesz nas wspierać:</h2>
+
<ul class="errorlist">
{% for e in form.non_field_errors %}
<li>{{ e }}</li>
{% endfor %}
- <h2>Metoda płatności</h2>
+ <h2>Wybierz metodę płatności:</h2>
<ul class="errorlist">
{% for e in form.method.errors %}
{% for payment_method in form.payment_methods %}
<div class="payment-method" id="payment-method-{{ payment_method.slug }}">
<input type="radio" id="method{{ payment_method.slug }}" name="method" value="{{ payment_method.slug }}">
- <label for="method{{ payment_method.slug }}" style="display:inline-block">
+ <label for="method{{ payment_method.slug }}">
{% include payment_method.template_name %}
</label>
</div>
{% endfor %}
- <p style="margin-top: 2em;">
- {{ form.email.label }}:
+ <h2>
+ Podaj nam swój adres e-mail, żebyśmy mogli się z Tobą skontaktować:
+ </h2>
+
+ <p>
{{ form.email }}</p>
<button class="submit" type='submit'>Dołącz</button>
</form>
+{% chunk 'club_form_bottom' %}
+
</div>
{% endblock %}
{% load staticfiles %}
-<img src="{% static 'club/payu/payu.png' %}" height="50">
-<span class="method">karta</span>
-<span class="method">⟳ płatność cykliczna</span>
-
+<img src="{% static 'club/payu/payu.png' %}">
+<img src="{% static 'club/visa-100.png' %}">
+<img src="{% static 'club/mastercard.png' %}">
++<br>Płatność cykliczna, odnawiana automatycznie.
{% load staticfiles %}
-<img src="{% static 'club/payu/payu.png' %}" height="50">
-<img src="{% static 'club/payu/blik.png' %}" height="50">
-<span class="method">karta</span>
+<img src="{% static 'club/payu/payu.png' %}">
+<img src="{% static 'club/payu/blik.png' %}">
+<img src="{% static 'club/visa-100.png' %}">
+<img src="{% static 'club/mastercard.png' %}">
<span class="method">przelew</span>
+<br>Płatność jednorazowa
{% block body %}
<div class="white-box normal-text">
-<h1>Plan płatności</h1>
-
-<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>
+<h1>
+Cieszymy się, że jesteś z nami! Dziękujemy za wsparcie!
+</h1>
+<p>
+Od <strong>{{ schedule.started_at.date }}</strong>
+{% if schedule.expires_at %}
+ do <strong>{{ schedule.expires_at.date }}</strong>
+{% endif %}
+wspierasz nas kwotą {{ schedule.amount }} zł {{ schedule.plan.get_interval_display }}.
+</p>
{% 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 %}">
+ {% if schedule.is_cancelled %}
+ <p><strong>Płatność anulowana.</strong></p>
+ <p>
+ <a style="background:#018189;color:white;border-radius: 10px;padding:1em 2em" href="/towarzystwo/dolacz/">Odnów składkę</a>
+ </p>
+ {% else %}
+ <form class="wlform" method='post' action="{% url 'club_cancel' schedule.key %}">
{% csrf_token %}
- <button type="submit">Anuluj kolejną płatność</button>
- </form>
+ <button type="submit" class="submit" style="font-size: .9em">Anuluj kolejną płatność</button>
+ </form>
+ {% endif %}
{% else %}
- <form method='post' action=''>
+ <form class="wlform" method='post' action=''>
{% csrf_token %}
- <button type="submit">Opłać kolejny okres</button>
- </form>
+ <button type="submit" class="submit">Opłać kolejny okres</button>
+ </form>
{% endif %}
{% else %}
{% if schedule.is_expired %}
Członkostwo wygasło.
- <form method='post' action=''>
+ <form method='post' action='' class="wlform">
{% csrf_token %}
- <button type="submit">Opłać kolejny okres</button>
+ <button type="submit" class="submit">Opłać kolejny okres</button>
</form>
<form method='post' action=''>
{% csrf_token %}
- <button type="submit">Zapłać składkę</button>
+ <button type="submit" class="submit">Zapłać składkę</button>
</form>
{% endif %}
{% endif %}
{% endif %}
-<hr>
+
+<hr style="margin: 2em 0;">
+<h2>Towarzystwo Przyjaciół Wolnych Lektur</h2>
+
{% if schedule.membership %}
<p>
- Członek/członkini Towarzystwa nr {{ schedule.membership.id }} ({{ schedule.membership.user }}).
- </p>
+ Należysz już do Towarzystwa Przyjaciół Wolnych Lektur!</p>
- <form method='post' action='{% url "club_membership" %}'>
+ <form class="wlform" method='post' action='{% url "club_membership" %}'>
{% csrf_token %}
- Imię i nazwisko na legitymację: <br>
+ Skontaktujemy się z Tobą w sprawie odbioru legitymacji członkowskiej.<br>Tutaj możesz podać imię i nazwisko, jakie ma na niej widnieć:<br>
<input name="name" value="{{ schedule.membership.name|default:schedule.membership.user.username }}"><br>
- <button type="submit">Zapisz</button>
+ <button class="submit" type="submit">Zmień dane</button>
</form>
{% else %}
+
+<p>
+Twoje wsparcie upoważnia Cię do członkostwa w Towarzystwie Przyjaciół Wolnych Lektur.
+Aby w pełni z niego korzystać, zapisz się do Towarzystwa swoim kontem użytkownika na Wolnych Lekturach.
+</p>
+
+
<p>
-Płatność nie przypisana do członkostwa.<br>
-<a href="{% url 'club_claim' schedule.key %}">Przypisz</a>
+<a style="background:#018189;color:white;border-radius: 10px;padding:1em 2em;" href="{% url 'club_claim' schedule.key %}">Zapisz się</a>
</p>
{% endif %}
--- /dev/null
+{% extends request.session.from_app|yesno:"base/app.html,base/base.html" %}
+{% load chunks %}
+
+
+{% block titleextra %}Towarzystwo Wolnych Lektur{% endblock %}
+
+
+{% block body %}
+
+
+<div class="white-box normal-text">
+
+ <h1>Dziękujemy</h1>
+
+
+{% chunk 'club_thanks' %}
+
+{% if request.session.from_app %}
+ <a href="wolnelekturyapp://paypal_return">Wróć do aplikacji</a>
+{% else %}
+{% endif %}
+
+</div>
+
+{% endblock %}
urlpatterns = [
- url(r'^$', views.ClubView.as_view()),
- url(r'^dolacz/$', views.JoinView.as_view(), name='club_join'),
+ url(r'^$', views.JoinView.as_view(), name='club_join'),
+ url(r'^info/$', views.ClubView.as_view(), name='club'),
url(r'^plan/(?P<key>[-a-z0-9]+)/$', views.ScheduleView.as_view(), name='club_schedule'),
+ url(r'^plan/(?P<key>[-a-z0-9]+)/dziekujemy/$', views.ScheduleThanksView.as_view(), name='club_thanks'),
+
url(r'^przylacz/(?P<key>[-a-z0-9]+)/$', views.claim, name='club_claim'),
url(r'^anuluj/(?P<key>[-a-z0-9]+)/$', views.cancel, name='club_cancel'),
url(r'^testowa-platnosc/(?P<key>[-a-z0-9]+)/$', views.DummyPaymentView.as_view(), name='club_dummy_payment'),
+from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
+from django.utils.decorators import method_decorator
+from django.views.decorators.cache import never_cache
from django.views.generic import FormView, CreateView, TemplateView, DetailView, UpdateView
from django.views import View
from .payu import POSS
class ClubView(TemplateView):
template_name = 'club/index.html'
+ def get_context_data(self, *args, **kwargs):
+ ctx = super().get_context_data(*args, **kwargs)
+ ctx['active_menu_item'] = 'club'
+ return ctx
+
class JoinView(CreateView):
form_class = ScheduleForm
return self.request.GET.get('app')
def get(self, request):
+ # TODO: configure as app-allowed hosts.
+ if settings.CLUB_APP_HOST and self.is_app() and request.META['HTTP_HOST'] != settings.CLUB_APP_HOST:
+ return HttpResponseRedirect("https://" + settings.CLUB_APP_HOST + request.get_full_path())
+
if self.is_app():
request.session['from_app'] = True
elif request.session and 'from_app' in request.session:
def get_context_data(self, **kwargs):
c = super(JoinView, self).get_context_data(**kwargs)
c['membership'] = getattr(self.request.user, 'membership', None)
- #if hasattr(form, 'errors'):
- # print(form.errors)
+ c['active_menu_item'] = 'club'
return c
def get_initial(self):
return self.object.initiate_payment(self.request)
+@method_decorator(never_cache, name='dispatch')
class ScheduleView(DetailView):
model = models.Schedule
slug_field = slug_url_kwarg = 'key'
template_name = 'club/schedule.html'
+ def get_context_data(self, *args, **kwargs):
+ ctx = super().get_context_data(*args, **kwargs)
+ ctx['active_menu_item'] = 'club'
+ return ctx
+
def post(self, request, key):
schedule = self.get_object()
return HttpResponseRedirect(schedule.initiate_payment(request))
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
+
CLUB_PAYU_POS = '300746'
CLUB_PAYU_RECURRING_POS = '300746'
-
+CLUB_APP_HOST = None
.wlform {
.payment-method {
+ margin-top: 2em;
+
input {
height: 50px;
vertical-align: middle;
img {
vertical-align: middle;
margin-right: 1em;
+ height: 36px;
}
label {
+ display: inline;
margin: .5em 0;
vertical-align: middle;
}
-
.method {
- // border: 1px solid black;
- border-radius: 10px;
- line-height: 48px;
+ border: 1px solid black;
+ border-radius: 5px;
+ line-height: 34px;
display: inline-block;
vertical-align: middle;
padding: 0 1em;
margin-right: 1em;
- font-size: 1.25em;
- background: #01818980;
- color: white;
+ color: black;
+ text-transform: uppercase;
}
}
}
<div id="whole-header">
<div id="header-wrapper">
<header id="main">
- <a href="/" id="logo">
+ <a href="https://wolnelektury.pl" id="logo">
<img src="{% static 'img/logo-neon.png' %}" alt="Wolne Lektury"/>
</a>
<li{% if active_menu_item == 'audiobooks' %} class="active"{% endif %}>
<a href="{% url 'audiobook_list' %}">{% trans "Audiobooks" %}</a>
</li>
- <li{% if active_menu_item == 'gallery' %} class="active"{% endif %}>
- <a href="{% url 'gallery' %}">{% trans "Gallery" %}</a>
+ <li{% if active_menu_item == 'club' %} class="active"{% endif %}>
+ <a href="{% url 'club_join' %}">{% trans "Wesprzyj nas" %}</a>
</li>
<li{% if active_menu_item == 'all_works' %} class="active"{% endif %}>
<a href="{% url 'catalogue' %}">{% trans "All works" %}</a>
<p><a href="{% url 'account_set_password' %}">{% trans "Password" %}</a></p>
<p><a href="{% url 'account_email' %}">{% trans "E-mail" %}</a></p>
<p><a href="{% url 'socialaccount_connections' %}">{% trans "Social accounts" %}</a></p>
+ {% if request.user.membership %}
+ <p><a href="{% url 'club_join' %}">Należysz do Towarzystwa Przyjaciół Wolnych Lektur</a></p>
+ {% endif %}
</div>
{% endblock %}
url(r'^isbn/', include('isbn.urls')),
url(r'^paypal/app-form/$', RedirectView.as_view(
- url='/towarzystwo/dolacz/?app=1', permanent=True)),
+ url='/towarzystwo/?app=1', permanent=False)),
+ url(r'^towarzystwo/dolacz/$', RedirectView.as_view(
+ url='/towarzystwo/', permanent=False)),
+
url(r'^paypal/', include('paypal.urls')),
url(r'^powiadomienie/', include('push.urls')),