from django.contrib import admin
from .models import Offer, Perk, Funding, Spent
-admin.site.register(Spent)
-admin.site.register(Offer)
-admin.site.register(Perk)
-admin.site.register(Funding)
+
+class OfferAdmin(admin.ModelAdmin):
+ model = Offer
+ list_display = ['title', 'author', 'target', 'sum', 'state', 'start', 'end', 'due']
+ search_fields = ['title', 'author']
+
+
+class PerkAdmin(admin.ModelAdmin):
+ model = Perk
+ list_display = ['name', 'price', 'end_date', 'offer']
+
+
+class FundingAdmin(admin.ModelAdmin):
+ model = Funding
+ list_display = ['payed_at', 'offer', 'amount', 'name', 'email']
+ search_fields = ['name', 'email', 'offer__title', 'offer__author']
+
+
+class SpentAdmin(admin.ModelAdmin):
+ model = Spent
+ list_display = ['book', 'amount', 'timestamp']
+ search_fields = ['book__title']
+
+
+admin.site.register(Offer, OfferAdmin)
+admin.site.register(Perk, PerkAdmin)
+admin.site.register(Funding, FundingAdmin)
+admin.site.register(Spent, SpentAdmin)
from .widgets import PerksAmountWidget
-class DummyForm(forms.Form):
+class FundingForm(forms.Form):
required_css_class = 'required'
amount = forms.DecimalField(label=_("Amount"), decimal_places=2,
widget=PerksAmountWidget())
- name = forms.CharField(label=_("Name"), required=False)
- anonymous = forms.BooleanField(label=_("Anonymously"),
- required=False,
- help_text=_("Check if you don't want your name to be visible publicly."))
- email = forms.EmailField(label=_("E-mail"),
- help_text=_("Won't be publicised."), required=False)
+ name = forms.CharField(label=_("Name"), required=False,
+ help_text=_("Optional name for public list of contributors. <br/>"
+ "Leave empty if you prefer to remain anonymous. <br/>"
+ "If we need any data for your perks, we'll get to you by e-mail anyway."))
+ email = forms.EmailField(label=_("Contact e-mail"),
+ help_text=_("Won't be publicised. <br/>"
+ "We'll use it to contact you about your perks and fundraiser status updates.<br/> "
+ "Leave empty if you prefer not to be contacted by us."), required=False)
def __init__(self, offer, *args, **kwargs):
self.offer = offer
- super(DummyForm, self).__init__(*args, **kwargs)
+ super(FundingForm, self).__init__(*args, **kwargs)
self.fields['amount'].widget.form_instance = self
def clean_amount(self):
name=self.cleaned_data['name'],
email=self.cleaned_data['email'],
amount=self.cleaned_data['amount'],
- anonymous=self.cleaned_data['anonymous'],
)
--- /dev/null
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Deleting field 'Funding.anonymous'
+ db.delete_column(u'funding_funding', 'anonymous')
+
+
+ def backwards(self, orm):
+ # Adding field 'Funding.anonymous'
+ db.add_column(u'funding_funding', 'anonymous',
+ self.gf('django.db.models.fields.BooleanField')(default=False),
+ keep_default=False)
+
+
+ models = {
+ 'catalogue.book': {
+ 'Meta': {'ordering': "('sort_key',)", 'object_name': 'Book'},
+ '_related_info': ('jsonfield.fields.JSONField', [], {'null': 'True', 'blank': 'True'}),
+ 'changed_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}),
+ 'common_slug': ('django.db.models.fields.SlugField', [], {'max_length': '120'}),
+ 'cover': ('catalogue.fields.EbookField', [], {'max_length': '100', 'null': 'True', 'format_name': "'cover'", 'blank': 'True'}),
+ 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}),
+ 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'epub_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'epub'", 'blank': 'True'}),
+ 'extra_info': ('jsonfield.fields.JSONField', [], {'default': "'{}'"}),
+ 'fb2_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'fb2'", 'blank': 'True'}),
+ 'gazeta_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}),
+ 'html_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'html'", 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language': ('django.db.models.fields.CharField', [], {'default': "'pol'", 'max_length': '3', 'db_index': 'True'}),
+ 'mobi_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'mobi'", 'blank': 'True'}),
+ 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['catalogue.Book']"}),
+ 'parent_number': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'pdf_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'pdf'", 'blank': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '120'}),
+ 'sort_key': ('django.db.models.fields.CharField', [], {'max_length': '120', 'db_index': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
+ 'txt_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'txt'", 'blank': 'True'}),
+ 'wiki_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}),
+ 'xml_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'xml'", 'blank': 'True'})
+ },
+ u'funding.funding': {
+ 'Meta': {'ordering': "['-payed_at']", 'object_name': 'Funding'},
+ 'amount': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '127', 'blank': 'True'}),
+ 'offer': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['funding.Offer']"}),
+ 'payed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'perks': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['funding.Perk']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ u'funding.offer': {
+ 'Meta': {'ordering': "['-end']", 'object_name': 'Offer'},
+ 'author': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'book': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Book']", 'null': 'True', 'blank': 'True'}),
+ 'due': ('django.db.models.fields.DateField', [], {}),
+ 'end': ('django.db.models.fields.DateField', [], {}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'redakcja_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'}),
+ 'start': ('django.db.models.fields.DateField', [], {}),
+ 'target': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ },
+ u'funding.perk': {
+ 'Meta': {'ordering': "['-price']", 'object_name': 'Perk'},
+ 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'offer': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['funding.Offer']", 'null': 'True', 'blank': 'True'}),
+ 'price': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'})
+ },
+ u'funding.spent': {
+ 'Meta': {'ordering': "['-timestamp']", 'object_name': 'Spent'},
+ 'amount': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
+ 'book': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Book']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'timestamp': ('django.db.models.fields.DateField', [], {})
+ }
+ }
+
+ complete_apps = ['funding']
\ No newline at end of file
--- /dev/null
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Adding field 'Perk.end_date'
+ db.add_column(u'funding_perk', 'end_date',
+ self.gf('django.db.models.fields.DateField')(null=True, blank=True),
+ keep_default=False)
+
+
+ def backwards(self, orm):
+ # Deleting field 'Perk.end_date'
+ db.delete_column(u'funding_perk', 'end_date')
+
+
+ models = {
+ 'catalogue.book': {
+ 'Meta': {'ordering': "('sort_key',)", 'object_name': 'Book'},
+ '_related_info': ('jsonfield.fields.JSONField', [], {'null': 'True', 'blank': 'True'}),
+ 'changed_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}),
+ 'common_slug': ('django.db.models.fields.SlugField', [], {'max_length': '120'}),
+ 'cover': ('catalogue.fields.EbookField', [], {'max_length': '100', 'null': 'True', 'format_name': "'cover'", 'blank': 'True'}),
+ 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}),
+ 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'epub_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'epub'", 'blank': 'True'}),
+ 'extra_info': ('jsonfield.fields.JSONField', [], {'default': "'{}'"}),
+ 'fb2_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'fb2'", 'blank': 'True'}),
+ 'gazeta_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}),
+ 'html_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'html'", 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language': ('django.db.models.fields.CharField', [], {'default': "'pol'", 'max_length': '3', 'db_index': 'True'}),
+ 'mobi_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'mobi'", 'blank': 'True'}),
+ 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['catalogue.Book']"}),
+ 'parent_number': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'pdf_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'pdf'", 'blank': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '120'}),
+ 'sort_key': ('django.db.models.fields.CharField', [], {'max_length': '120', 'db_index': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
+ 'txt_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'txt'", 'blank': 'True'}),
+ 'wiki_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}),
+ 'xml_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'xml'", 'blank': 'True'})
+ },
+ u'funding.funding': {
+ 'Meta': {'ordering': "['-payed_at']", 'object_name': 'Funding'},
+ 'amount': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '127', 'blank': 'True'}),
+ 'offer': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['funding.Offer']"}),
+ 'payed_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'perks': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['funding.Perk']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ u'funding.offer': {
+ 'Meta': {'ordering': "['-end']", 'object_name': 'Offer'},
+ 'author': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'book': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Book']", 'null': 'True', 'blank': 'True'}),
+ 'due': ('django.db.models.fields.DateField', [], {}),
+ 'end': ('django.db.models.fields.DateField', [], {}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'redakcja_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'}),
+ 'start': ('django.db.models.fields.DateField', [], {}),
+ 'target': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ },
+ u'funding.perk': {
+ 'Meta': {'ordering': "['-price']", 'object_name': 'Perk'},
+ 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'end_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'offer': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['funding.Offer']", 'null': 'True', 'blank': 'True'}),
+ 'price': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'})
+ },
+ u'funding.spent': {
+ 'Meta': {'ordering': "['-timestamp']", 'object_name': 'Spent'},
+ 'amount': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
+ 'book': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Book']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'timestamp': ('django.db.models.fields.DateField', [], {})
+ }
+ }
+
+ complete_apps = ['funding']
\ No newline at end of file
"""
perks = Perk.objects.filter(
models.Q(offer=self) | models.Q(offer=None)
- )
+ ).exclude(end_date__lt=date.today())
if amount is not None:
perks = perks.filter(price__lte=amount)
return perks
price = models.DecimalField(_('price'), decimal_places=2, max_digits=10)
name = models.CharField(_('name'), max_length=255)
description = models.TextField(_('description'), blank=True)
+ end_date = models.DateField(_('end date'), null=True, blank=True)
class Meta:
verbose_name = _('perk')
amount = models.DecimalField(_('amount'), decimal_places=2, max_digits=10)
payed_at = models.DateTimeField(_('payed at'), null=True, blank=True)
perks = models.ManyToManyField(Perk, verbose_name=_('perks'), blank=True)
- anonymous = models.BooleanField(_('anonymous'))
+
+ # Any additional info needed for perks?
@classmethod
def payed(cls):
ordering = ['-payed_at']
def __unicode__(self):
- return "%s payed %s for %s" % (self.name, self.amount, self.offer)
+ return unicode(self.offer)
def get_absolute_url(self):
return reverse('funding_funding', args=[self.pk])
class Spent(models.Model):
""" Some of the remaining money spent on a book. """
+ book = models.ForeignKey(Book)
amount = models.DecimalField(_('amount'), decimal_places=2, max_digits=10)
timestamp = models.DateField(_('when'))
- book = models.ForeignKey(Book)
class Meta:
verbose_name = _('money spent on a book')
-a.funding{font-size:1.5em;padding:.5em 1em;display:block;color:#000;background-image:url(/static/img/green-pixel.png);background-repeat:repeat-y;background-color:rgba(13, 126, 133, .2)}a.funding .mono{font-size:.9em}.wlfund{width:100%;border-collapse:collapse}.wlfund td{padding:0 0 1em 0;text-align:center}.wlfund td:last-child{text-align:right}.wlfund td div{padding:1em;box-shadow:0 2px 0 #DDD}.wlfund .funding-plus td div{background:rgba(13, 126, 133, .2)}.wlfund .funding-minus td div{bbackground:rgba(255, 0, 0, .2);background:#fff}.funding-stale .funding{opacity:.5}
\ No newline at end of file
+a.funding{font-size:1.5em;padding:.5em 1em;display:block;color:#000;background-image:url(/static/img/green-pixel.png);background-repeat:repeat-y;background-color:rgba(13, 126, 133, .2)}a.funding .mono{font-size:.9em}.wlfund{width:100%;border-collapse:collapse}.wlfund td{padding:0 0 1em 0;text-align:center}.wlfund td:last-child{text-align:right}.wlfund td div{padding:1em;box-shadow:0 2px 0 #DDD}.wlfund .funding-plus td div{background:rgba(13, 126, 133, .2)}.wlfund .funding-minus td div{bbackground:rgba(255, 0, 0, .2);background:#fff}.funding-stale .funding{opacity:.5}button.honking{background:#018189;font-size:1.5em;padding:.5em;color:#fff;border:0}button.honking:hover{background:rgb(.537%, 69.284%, 73.581%)}
\ No newline at end of file
opacity: .5;
}
}
+
+
+button.honking {
+ background: #018189;
+ font-size: 1.5em;
+ padding: .5em;
+ color: white;
+ border: 0;
+}
+button.honking:hover {
+ background: lighten(#018189, .1);
+}
+++ /dev/null
-{% extends "base.html" %}
-{% load i18n %}
-{% load funding_tags %}
-{% load fnp_share %}
-
-
-{% block titleextra %}
- {% if object.payed_at %}
- {% trans "Thank you!" %}
- {% else %}
- {{ object }}
- {% endif %}
-{% endblock %}
-
-
-{% block body %}
-
-
-{% if object.payed_at %}
-
-<h1>{% trans "Thank you!" %}</h1>
-<div class="white-box normal-text">
-
-{% trans "Thank you for your support!" %}
-
-
-
-{% url 'funding_current' as current %}
-<p><a href="{{ current }}">{% trans "Go back to the current fundraiser." %}</a></p>
-
-{% url 'funding_current' as current %}
-<p>{% share current 'y' %}</p>
-
-</div>
-
-
-
-{% else %}
-
-
-<h1>{{ object }}</h1>
-
-<div class="white-box normal-text">
-<form action="{% url 'getpaid-new-payment' currency='PLN' %}" method="post">
- {% csrf_token %}
- {{ payment_form.as_p }}
- <input type="submit" value="Continue">
-</form>
-</div>
-
-
-{% endif %}
-{% endblock %}
--- /dev/null
+{% extends "base.html" %}
+{% load i18n %}
+{% load fnp_share %}
+
+{% block titleextra %}{% trans "Payment failed" %}{% endblock %}
+
+{% block body %}
+
+<h1>{% trans "Payment failed" %}</h1>
+<div class="white-box normal-text">
+
+<p>{% trans "You're support has not been processed successfully." %}</p>
+
+
+{% url 'funding_current' as current %}
+
+<p><a href="{{ current }}">{% trans "Go back to the current fundraiser." %}</a></p>
+
+</div>
+
+
+{% endblock %}
{% csrf_token %}
<table>
{{ form.as_table }}
- <tr><td></td><td><button type="submit">Wpłać!</button></td></tr>
+ <tr><td></td><td><button class="honking" type="submit">Wpłać!</button></td></tr>
</table>
</form>
<tr class="funding-plus">
<td><div>{{ funding.payed_at.date }}</div></td>
<td><div>
- {% if funding.anonymous %}
- <em>{% trans "Anonymous" %}</em>
- {% else %}
+ {% if funding.name %}
{{ funding.name }}
+ {% else %}
+ <em>{% trans "Anonymous" %}</em>
{% endif %}
</div></td>
<td><div>+{{ funding.amount }} zł</div></td>
{% trans "Thank you for your support!" %}
+{% url 'funding_current' as c %}
+<p>{% blocktrans %}Your support will appear on the <a href="{{ c }}">
+current fundraiser page</a> shortly.{% endblocktrans %}</p>
-{% url 'funding_current' as current %}
-<p><a href="{{ current }}">{% trans "Go back to the current fundraiser." %}</a></p>
+<p>{% trans "Tell your friends about the fundraiser!" %}</p>
-{% url 'funding_current' as current %}
-<p>{% share current 'y' %}</p>
+<p>{% share current _("I support Wolne Lektury.") %}</p>
</div>
{% load i18n %}
+<div style="font-size: 1.5em; line-height:1.5em;">
{% if perks %}
{% for perk in perks %}
<label>
{% else %}
<input name="{{ name }}" value="{{ value|default_if_none:'' }}" {% if value != None %}{% endif %} />
{% endif %}
+</div>
from .models import Offer
from .views import (WLFundView, OfferDetailView, OfferListView,
- FundingView)
+ ThanksView, NoThanksView)
urlpatterns = patterns('',
url(r'^$', OfferDetailView.as_view(), name='funding_current'),
url(r'^lektura/$', OfferListView.as_view(), name='funding'),
url(r'^lektura/(?P<slug>[^/]+)/$', OfferDetailView.as_view(), name='funding_offer'),
- url(r'^wplata/(?P<pk>\d+)/$', FundingView.as_view(), name='funding_funding'),
url(r'^fundusz/$', WLFundView.as_view(), name='funding_wlfund'),
+
+ url(r'^dziekujemy/$', ThanksView.as_view(), name='funding_thanks'),
+ url(r'^niepowodzenie/$', NoThanksView.as_view(), name='funding_nothanks'),
+
url(r'^getpaid/', include('getpaid.urls')),
)
from django.shortcuts import redirect, get_object_or_404
from django.utils.decorators import method_decorator
from django.views.generic import TemplateView, FormView, DetailView, ListView
-from getpaid.forms import PaymentMethodForm
-from .forms import DummyForm
+import getpaid.backends.payu
+from getpaid.models import Payment
+from .forms import FundingForm
from .models import Offer, Spent, Funding
class OfferDetailView(FormView):
- form_class = DummyForm
+ form_class = FundingForm
template_name = "funding/offer_detail.html"
+ backend = 'getpaid.backends.payu'
def dispatch(self, request, slug=None):
if slug:
ctx['object'] = self.object
if self.object.is_current():
ctx['funding_no_show_current'] = True
- ctx['payment_form'] = PaymentMethodForm('PLN', initial={'order': self.object})
return ctx
def form_valid(self, form):
funding = form.save()
- return redirect(funding.get_absolute_url())
+ # Skip getpaid.forms.PaymentMethodForm, go directly to the broker.
+ payment = Payment.create(funding, self.backend)
+ gateway_url = payment.get_processor()(payment).get_gateway_url(self.request)
+ payment.change_status('in_progress')
+ return redirect(gateway_url)
class OfferListView(ListView):
return ctx
-class FundingView(DetailView):
- model = Funding
-
- @method_decorator(never_cache)
- def dispatch(self, *args, **kwargs):
- return super(FundingView, self).dispatch(*args, **kwargs)
+class ThanksView(TemplateView):
+ template_name = "funding/thanks.html"
def get_context_data(self, *args, **kwargs):
- ctx = super(FundingView, self).get_context_data(*args, **kwargs)
- if self.object.offer.is_current():
- ctx['funding_no_show_current'] = True
- ctx['payment_form'] = PaymentMethodForm('PLN', initial={'order': self.object})
+ ctx = super(ThanksView, self).get_context_data(*args, **kwargs)
+ ctx['funding_no_show_current'] = True
return ctx
+class NoThanksView(TemplateView):
+ template_name = "funding/no_thanks.html"