From: Radek Czajka Date: Thu, 18 Apr 2013 13:54:27 +0000 (+0200) Subject: Skip getpaid's PaymentMethodForm, X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/ff132bd3bbbad657112d7a7d9e16fe7530055b3f?hp=0f1d9c82677e949f5333447343ae72f45d4841be Skip getpaid's PaymentMethodForm, remove 'anonymous' option, simply allow anonymous payments instead, nicer admin pages for funding. --- diff --git a/apps/funding/admin.py b/apps/funding/admin.py index 7fbb4c488..37adaf111 100755 --- a/apps/funding/admin.py +++ b/apps/funding/admin.py @@ -1,7 +1,31 @@ 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) diff --git a/apps/funding/forms.py b/apps/funding/forms.py index c66211a71..bc66e5d42 100755 --- a/apps/funding/forms.py +++ b/apps/funding/forms.py @@ -4,21 +4,23 @@ from .models import Funding 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.
" + "Leave empty if you prefer to remain anonymous.
" + "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.
" + "We'll use it to contact you about your perks and fundraiser status updates.
" + "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): @@ -37,6 +39,5 @@ class DummyForm(forms.Form): name=self.cleaned_data['name'], email=self.cleaned_data['email'], amount=self.cleaned_data['amount'], - anonymous=self.cleaned_data['anonymous'], ) diff --git a/apps/funding/migrations/0006_auto__del_field_funding_anonymous.py b/apps/funding/migrations/0006_auto__del_field_funding_anonymous.py new file mode 100644 index 000000000..9a059a4d4 --- /dev/null +++ b/apps/funding/migrations/0006_auto__del_field_funding_anonymous.py @@ -0,0 +1,89 @@ +# -*- 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 diff --git a/apps/funding/migrations/0007_auto__add_field_perk_end_date.py b/apps/funding/migrations/0007_auto__add_field_perk_end_date.py new file mode 100644 index 000000000..25f15b25d --- /dev/null +++ b/apps/funding/migrations/0007_auto__add_field_perk_end_date.py @@ -0,0 +1,90 @@ +# -*- 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 diff --git a/apps/funding/models.py b/apps/funding/models.py index 10243132c..31e2757eb 100644 --- a/apps/funding/models.py +++ b/apps/funding/models.py @@ -62,7 +62,7 @@ class Offer(models.Model): """ 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 @@ -94,6 +94,7 @@ class Perk(models.Model): 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') @@ -116,7 +117,8 @@ class Funding(models.Model): 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): @@ -129,7 +131,7 @@ class Funding(models.Model): 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]) @@ -140,9 +142,9 @@ getpaid.register_to_payment(Funding, unique=False, related_name='payment') 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') diff --git a/apps/funding/static/funding/funding.css b/apps/funding/static/funding/funding.css index 538477390..aa99d1d27 100755 --- a/apps/funding/static/funding/funding.css +++ b/apps/funding/static/funding/funding.css @@ -1 +1 @@ -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 diff --git a/apps/funding/static/funding/funding.scss b/apps/funding/static/funding/funding.scss index 435b0ac40..7a158d24e 100755 --- a/apps/funding/static/funding/funding.scss +++ b/apps/funding/static/funding/funding.scss @@ -47,3 +47,15 @@ a.funding { opacity: .5; } } + + +button.honking { + background: #018189; + font-size: 1.5em; + padding: .5em; + color: white; + border: 0; +} +button.honking:hover { + background: lighten(#018189, .1); +} diff --git a/apps/funding/templates/funding/funding_detail.html b/apps/funding/templates/funding/funding_detail.html deleted file mode 100755 index 617426d5a..000000000 --- a/apps/funding/templates/funding/funding_detail.html +++ /dev/null @@ -1,53 +0,0 @@ -{% 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 %} - -

{% trans "Thank you!" %}

-
- -{% trans "Thank you for your support!" %} - - - -{% url 'funding_current' as current %} -

{% trans "Go back to the current fundraiser." %}

- -{% url 'funding_current' as current %} -

{% share current 'y' %}

- -
- - - -{% else %} - - -

{{ object }}

- -
-
- {% csrf_token %} - {{ payment_form.as_p }} - -
-
- - -{% endif %} -{% endblock %} diff --git a/apps/funding/templates/funding/no_thanks.html b/apps/funding/templates/funding/no_thanks.html new file mode 100755 index 000000000..64ff3c814 --- /dev/null +++ b/apps/funding/templates/funding/no_thanks.html @@ -0,0 +1,22 @@ +{% extends "base.html" %} +{% load i18n %} +{% load fnp_share %} + +{% block titleextra %}{% trans "Payment failed" %}{% endblock %} + +{% block body %} + +

{% trans "Payment failed" %}

+
+ +

{% trans "You're support has not been processed successfully." %}

+ + +{% url 'funding_current' as current %} + +

{% trans "Go back to the current fundraiser." %}

+ +
+ + +{% endblock %} diff --git a/apps/funding/templates/funding/offer_detail.html b/apps/funding/templates/funding/offer_detail.html index c7405cad8..3aa4c92c5 100755 --- a/apps/funding/templates/funding/offer_detail.html +++ b/apps/funding/templates/funding/offer_detail.html @@ -24,7 +24,7 @@ {% csrf_token %} {{ form.as_table }} - +
@@ -45,10 +45,10 @@
{{ funding.payed_at.date }}
- {% if funding.anonymous %} - {% trans "Anonymous" %} - {% else %} + {% if funding.name %} {{ funding.name }} + {% else %} + {% trans "Anonymous" %} {% endif %}
+{{ funding.amount }} zł
diff --git a/apps/funding/templates/funding/thanks.html b/apps/funding/templates/funding/thanks.html index f3ca19f6f..fdf0ae6df 100755 --- a/apps/funding/templates/funding/thanks.html +++ b/apps/funding/templates/funding/thanks.html @@ -11,13 +11,14 @@ {% trans "Thank you for your support!" %} +{% url 'funding_current' as c %} +

{% blocktrans %}Your support will appear on the +current fundraiser page shortly.{% endblocktrans %}

-{% url 'funding_current' as current %} -

{% trans "Go back to the current fundraiser." %}

+

{% trans "Tell your friends about the fundraiser!" %}

-{% url 'funding_current' as current %} -

{% share current 'y' %}

+

{% share current _("I support Wolne Lektury.") %}

diff --git a/apps/funding/templates/funding/widgets/amount.html b/apps/funding/templates/funding/widgets/amount.html index edb7a51a1..28470684d 100644 --- a/apps/funding/templates/funding/widgets/amount.html +++ b/apps/funding/templates/funding/widgets/amount.html @@ -1,4 +1,5 @@ {% load i18n %} +
{% if perks %} {% for perk in perks %}
diff --git a/apps/funding/urls.py b/apps/funding/urls.py index c930c60aa..6b60035c3 100755 --- a/apps/funding/urls.py +++ b/apps/funding/urls.py @@ -6,14 +6,17 @@ from django.conf.urls import patterns, url, include 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[^/]+)/$', OfferDetailView.as_view(), name='funding_offer'), - url(r'^wplata/(?P\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')), ) diff --git a/apps/funding/views.py b/apps/funding/views.py index 047be49ab..4db8267ef 100644 --- a/apps/funding/views.py +++ b/apps/funding/views.py @@ -9,8 +9,9 @@ from django.http import Http404 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 @@ -71,8 +72,9 @@ class WLFundView(TemplateView): 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: @@ -94,12 +96,15 @@ class OfferDetailView(FormView): 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): @@ -111,17 +116,13 @@ 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"