plan_id = plan.plan_id
start = (timezone.now() + timedelta(0, 3600*24)).astimezone(pytz.utc).strftime('%Y-%m-%dT%H:%M:%SZ')
billing_agreement = BillingAgreement({
- "name": "Subskrypcja klubu WL",
- "description": "Cykliczne wspieranie Wolnych Lektur kwotą %s złotych" % amount,
+ "name": u"Subskrypcja klubu WL",
+ "description": u"Stałe wsparcie Wolnych Lektur kwotą %s złotych" % amount,
"start_date": start,
"plan": {
"id": plan_id,
{% block title %}{% trans "Subscription" %}{% endblock %}
{% block body %}
- <form method="post">
- {% csrf_token %}
- {{ form.as_p }}
- {# paypal submit button #}
- <button type="submit">{% trans "Subscribe with PayPal" %}</button>
- </form>
+ {# https://www.facebook.com/sharer/sharer.php?u=https%3A//wolnelektury.pl{% url 'paypal_form' %} #}
+ {% if user.is_authenticated %}
+ <form method="post">
+ {% csrf_token %}
+ {{ form.as_p }}
+ {# paypal submit button #}
+ <button type="submit">{% trans "Subscribe with PayPal" %}</button>
+ </form>
+ {% else %}
+ {% trans "You must be logged in to subscribe." %}
+ {% endif %}
{% endblock %}
\ No newline at end of file
from django.contrib.auth.decorators import login_required
from django.http import Http404
-from django.http.response import HttpResponseRedirect
+from django.http.response import HttpResponseRedirect, HttpResponseForbidden
from django.shortcuts import render
from paypal.forms import PaypalSubscriptionForm
from paypal.models import BillingAgreement as BillingAgreementModel, BillingPlan
-@login_required
def paypal_form(request):
if request.POST:
+ if not request.user.is_authenticated():
+ return HttpResponseForbidden()
form = PaypalSubscriptionForm(data=request.POST)
if form.is_valid():
amount = form.cleaned_data['amount']