From: Radek Czajka Date: Thu, 25 Apr 2013 11:08:36 +0000 (+0200) Subject: Different handling of current payment view, X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/dac9a35e0d86c0ec50f33d69d73be5d7ae7ae7ef?ds=inline;hp=-c Different handling of current payment view, add share icons, set email for payment broker, getpaid-1.4, reqs fix. --- dac9a35e0d86c0ec50f33d69d73be5d7ae7ae7ef diff --git a/apps/funding/admin.py b/apps/funding/admin.py old mode 100755 new mode 100644 diff --git a/apps/funding/forms.py b/apps/funding/forms.py old mode 100755 new mode 100644 index bc66e5d42..6eba5175b --- a/apps/funding/forms.py +++ b/apps/funding/forms.py @@ -15,7 +15,7 @@ class FundingForm(forms.Form): "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.
" + "We'll use it to contact you about your perks and fundraiser status and payment updates.
" "Leave empty if you prefer not to be contacted by us."), required=False) def __init__(self, offer, *args, **kwargs): diff --git a/apps/funding/locale/pl/LC_MESSAGES/django.mo b/apps/funding/locale/pl/LC_MESSAGES/django.mo index 866363abe..15d8b9838 100644 Binary files a/apps/funding/locale/pl/LC_MESSAGES/django.mo and b/apps/funding/locale/pl/LC_MESSAGES/django.mo differ diff --git a/apps/funding/locale/pl/LC_MESSAGES/django.po b/apps/funding/locale/pl/LC_MESSAGES/django.po index 86dc282b6..2f7c0c56b 100644 --- a/apps/funding/locale/pl/LC_MESSAGES/django.po +++ b/apps/funding/locale/pl/LC_MESSAGES/django.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-04-25 10:52+0200\n" -"PO-Revision-Date: 2013-04-25 10:52+0100\n" +"POT-Creation-Date: 2013-04-25 13:01+0200\n" +"PO-Revision-Date: 2013-04-25 13:03+0100\n" "Last-Translator: Radek Czajka \n" "Language-Team: LANGUAGE \n" "Language: \n" @@ -18,7 +18,7 @@ msgstr "" "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n" #: forms.py:10 -#: templates/funding/wlfund.html:25 +#: templates/funding/wlfund.html:28 msgid "Amount" msgstr "Kwota" @@ -35,8 +35,8 @@ msgid "Contact e-mail" msgstr "E-mail kontaktowy" #: forms.py:17 -msgid "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." -msgstr "Nie będzie publikowany.
Użyjemy go do kontaktowania się z Tobą w sprawie prezentów i informacji o zmianach statusu zbiórki.
Zostaw puste, jeśli nie chcesz abyśmy się z Tobą kontaktowali." +msgid "Won't be publicised.
We'll use it to contact you about your perks and fundraiser status and payment updates.
Leave empty if you prefer not to be contacted by us." +msgstr "Nie będzie publikowany.
Użyjemy go do kontaktu w sprawie prezentów i informacji o zmianach statusu zbiórki i płatności.
Nie wypełniaj, jeśli nie chcesz abyśmy się z Tobą kontaktowali." #: models.py:15 msgid "author" @@ -51,7 +51,7 @@ msgid "slug" msgstr "slug" #: models.py:18 -#: models.py:100 +#: models.py:106 msgid "description" msgstr "opis" @@ -84,8 +84,8 @@ msgid "Published book." msgstr "Opublikowana książka." #: models.py:29 -#: models.py:97 -#: models.py:118 +#: models.py:103 +#: models.py:124 msgid "offer" msgstr "zbiórka" @@ -93,58 +93,58 @@ msgstr "zbiórka" msgid "offers" msgstr "zbiórki" -#: models.py:98 +#: models.py:104 msgid "price" msgstr "cena" -#: models.py:99 -#: models.py:119 +#: models.py:105 +#: models.py:125 msgid "name" msgstr "nazwa" -#: models.py:101 +#: models.py:107 msgid "end date" msgstr "data końcowa" -#: models.py:104 +#: models.py:110 msgid "perk" msgstr "prezent" -#: models.py:105 -#: models.py:123 +#: models.py:111 +#: models.py:129 msgid "perks" msgstr "prezenty" -#: models.py:120 +#: models.py:126 msgid "email" msgstr "e-mail" -#: models.py:121 -#: models.py:150 +#: models.py:127 +#: models.py:156 msgid "amount" msgstr "kwota" -#: models.py:122 +#: models.py:128 msgid "payed at" msgstr "data wpłaty" -#: models.py:133 +#: models.py:139 msgid "funding" msgstr "wpłata" -#: models.py:134 +#: models.py:140 msgid "fundings" msgstr "wpłaty" -#: models.py:151 +#: models.py:157 msgid "when" msgstr "kiedy" -#: models.py:154 +#: models.py:160 msgid "money spent on a book" msgstr "pieniądze wydane na książkę" -#: models.py:155 +#: models.py:161 msgid "money spent on books" msgstr "pieniądze wydane na książki" @@ -158,27 +158,42 @@ msgid "You're support has not been processed successfully." msgstr "Twoje wsparcie nie zostało zaksięgowane." #: templates/funding/no_thanks.html:17 -#: templates/funding/thanks.html:29 +#: templates/funding/thanks.html:31 msgid "Go back to the current fundraiser." msgstr "Wróć do aktualnej zbiórki." -#: templates/funding/offer_detail.html:24 +#: templates/funding/offer_detail.html:25 +#: templates/funding/thanks.html:28 +#: templates/funding/wlfund.html:17 +msgid "Learn more" +msgstr "Dowiedz się więcej" + +#: templates/funding/offer_detail.html:31 msgid "Support the publication" msgstr "Wesprzyj publikację" -#: templates/funding/offer_detail.html:29 +#: templates/funding/offer_detail.html:38 msgid "Donate!" msgstr "Wpłać!" -#: templates/funding/offer_detail.html:35 +#: templates/funding/offer_detail.html:46 +#: templates/funding/thanks.html:34 +msgid "Tell your friends!" +msgstr "Powiedz swoim znajomym!" + +#: templates/funding/offer_detail.html:47 +msgid "Support Wolne Lektury!" +msgstr "Wesprzyj Wolne Lektury!" + +#: templates/funding/offer_detail.html:50 msgid "See all fundraisers." msgstr "Zobacz wszystkie zbiórki." -#: templates/funding/offer_detail.html:40 +#: templates/funding/offer_detail.html:55 msgid "Supporters" msgstr "Wpłaty" -#: templates/funding/offer_detail.html:54 +#: templates/funding/offer_detail.html:69 msgid "Anonymous" msgstr "Anonim" @@ -192,7 +207,7 @@ msgid "Current fundraiser:" msgstr "Aktualna zbiórka:" #: templates/funding/offer_list.html:22 -#: templates/funding/offer_list.html:38 +#: templates/funding/offer_list.html:37 msgid "Previous fundraisers:" msgstr "Poprzednie zbiórki:" @@ -225,13 +240,9 @@ msgid "" " donation will be spent on publishing\n" " the book %(b)s if the full amount is raised by %(end)s.\n" " The book will then be published by %(due)s." -msgstr "Pieniądze przez Ciebie wpłacone zostaną przekazane napublikację książki %(b)s, jeśli do %(end)s uda nam się zebrać pełnąkwotę potrzebną na digitalizację, redakcję techniczną i literacką.Książka zostanie wówczas opublikowana do %(due)s." - -#: templates/funding/thanks.html:32 -msgid "Tell your friends!" -msgstr "Powiedz swoim znajomym!" +msgstr "Pieniądze przez Ciebie wpłacone zostaną przekazane na publikację książki %(b)s, jeśli do %(end)s uda nam się zebrać pełną kwotę potrzebną na digitalizację, redakcję techniczną i literacką. Książka zostanie wówczas opublikowana do %(due)s." -#: templates/funding/thanks.html:34 +#: templates/funding/thanks.html:35 msgid "I support Wolne Lektury." msgstr "Wspieram Wolne Lektury" @@ -248,29 +259,29 @@ msgid "" "the funds are spent on other books waiting for\n" "publication. The same thing happens with any money remaining\n" "from successful fundraisers." -msgstr "Jeśli nie udało się zebrać pełnej kwoty potrzebnej do opublikowaniaksiążki, środki przekazujemy na redakcję innych utworów oczekujących napublikację w serwisie. Na ten celprzekazujemy również pozostałe środki ze zbiórek ukończonych sukcesem." +msgstr "Jeśli nie udało się zebrać pełnej kwoty potrzebnej do opublikowania książki, środki przekazujemy na redakcję innych utworów oczekujących na publikację w serwisie. Na ten cel przekazujemy również nadmiarowe środki ze zbiórek ukończonych sukcesem." -#: templates/funding/wlfund.html:16 +#: templates/funding/wlfund.html:19 msgid "Spending these remaining funds is recorded in this table." msgstr "W poniższej tabeli rejetrujemy wydatkowanie tych środków." -#: templates/funding/wlfund.html:23 +#: templates/funding/wlfund.html:26 msgid "Date" msgstr "Data" -#: templates/funding/wlfund.html:24 +#: templates/funding/wlfund.html:27 msgid "Title" msgstr "Tytuł" -#: templates/funding/wlfund.html:26 +#: templates/funding/wlfund.html:29 msgid "Balance" msgstr "Bilans" -#: templates/funding/wlfund.html:33 +#: templates/funding/wlfund.html:36 msgid "Money spent on publishing the book" msgstr "Pieniądze przeznaczone na opublikowanie książki" -#: templates/funding/wlfund.html:42 +#: templates/funding/wlfund.html:45 msgid "Money remaining from the fundraiser for" msgstr "Pieniądze pozostałe ze zbiórki na" @@ -285,15 +296,15 @@ msgstr "Wszelkie pozostałe środki przeznaczymy na i msgid "Support a book!" msgstr "Wesprzyj kolejną publikację!" -#: templates/funding/tags/funding.html:21 +#: templates/funding/tags/funding.html:20 msgid "collected" msgstr "zebrane" -#: templates/funding/tags/funding.html:24 +#: templates/funding/tags/funding.html:23 msgid "missing" msgstr "brakuje" -#: templates/funding/tags/funding.html:27 +#: templates/funding/tags/funding.html:26 msgid "until fundraiser end" msgstr "do końca zbiórki" diff --git a/apps/funding/models.py b/apps/funding/models.py index de90226f3..d193b41c4 100644 --- a/apps/funding/models.py +++ b/apps/funding/models.py @@ -60,11 +60,17 @@ class Offer(models.Model): except IndexError: return None + @classmethod + def past(cls): + """ QuerySet for all current and past fundraisers. """ + today = date.today() + return cls.objects.filter(end__lt=today) + @classmethod def public(cls): """ QuerySet for all current and past fundraisers. """ today = date.today() - return cls.objects.filter(start__lte=today) + return cls.objects.filter(start__lte=today) def get_perks(self, amount=None): """ Finds all the perks for the offer. @@ -166,6 +172,11 @@ def new_payment_query_listener(sender, order=None, payment=None, **kwargs): getpaid.signals.new_payment_query.connect(new_payment_query_listener) +def user_data_query_listener(sender, order, user_data, **kwargs): + """ Set user data for payment. """ + user_data['email'] = order.email +getpaid.signals.user_data_query.connect(user_data_query_listener) + def payment_status_changed_listener(sender, instance, old_status, new_status, **kwargs): """ React to status changes from getpaid. """ if old_status != 'paid' and new_status == 'paid': diff --git a/apps/funding/static/funding/funding.css b/apps/funding/static/funding/funding.css index 9b458a2db..56cac3f73 100755 --- a/apps/funding/static/funding/funding.css +++ b/apps/funding/static/funding/funding.css @@ -1 +1 @@ -.funding{background:orange}.funding a.call{font-size:1.5em;height:1.2em;width:13em;position:relative;padding:.35em .5em;margin:.5em;display:inline-block;vertical-align:top;box-shadow:.2em .2em .3em #888;text-align:center;background:#fff;color:#4E56C8}.funding a.call:hover{box-shadow:none;top:.1em;left:.1em}.funding .description{display:inline-block;padding-left:.6em}.funding strong{font-size:1.5em;padding:.2em .2em 0;display:block}.funding strong a{color:#000}.funding .progress{width:95.7em;margin:.1em .3em .4em;border-radius:2em;background-image:url(/static/img/progress-pixel.png);background-repeat:repeat-y;background-color:rgba(236, 109, 0, .5);box-shadow:.1em .1em .1em #888}.funding .progress .piece{font-size:1.3em;padding:.3em .5em}.funding .with-button .progress{width:73em}.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{background:#fff}button.honking{background:#018189;font-size:1.5em;padding:.5em;color:#fff;border:0;box-shadow:.2em .2em .3em #888;position:relative}button.honking:hover{box-shadow:none;top:.1em;left:.1em} \ No newline at end of file +.funding{background:orange}.funding a.call{height:1.2em;width:13em;padding:.35em .5em;margin:.5em;display:inline-block;vertical-align:top;text-align:center;background:rgb(.465%, 59.936%, 63.653%)}.funding .description{display:inline-block;padding-left:.6em}.funding .description a{display:block;color:#000}.funding strong{font-size:1.5em;padding:.2em .2em 0;display:block}.funding .progress{width:95.7em;margin:.1em .3em .4em;border-radius:2em;background-image:url(/static/img/progress-pixel.png);background-repeat:repeat-y;background-color:rgba(236, 109, 0, .5);box-shadow:.1em .1em .1em #888}.funding .progress .piece{font-size:1.3em;padding:.3em .5em}.funding .with-button .progress{width:73em}.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{background:#fff}.honking{background:#018189;font-size:1.5em;padding:.5em;color:#fff;border:0;box-shadow:.2em .2em .3em #888;position:relative}.honking:hover{box-shadow:none;top:.1em;left:.1em}.share a{margin-right:1.5em}.share a img{vertical-align:middle} \ No newline at end of file diff --git a/apps/funding/static/funding/funding.scss b/apps/funding/static/funding/funding.scss index 44109ee9c..ef766f506 100755 --- a/apps/funding/static/funding/funding.scss +++ b/apps/funding/static/funding/funding.scss @@ -2,35 +2,28 @@ background: orange; a.call { - font-size: 1.5em; height: 1.2em; width: 13em; - position: relative; padding: .35em .5em; margin: .5em; display: inline-block; vertical-align: top; - box-shadow: 0.2em 0.2em 0.3em #888888; text-align: center; - background: white; - color: #4E56C8; - } - a.call:hover { - box-shadow: none; - top: .1em; - left: .1em; + + background: lighten(#018189, .05); } .description { display: inline-block; padding-left: .6em; + a { + display: block; + color: black; + } } strong { font-size: 1.5em; padding: .2em .2em 0; display: block; - a { - color: black; - } } .progress { .piece { @@ -82,7 +75,7 @@ -button.honking { +.honking { background: #018189; font-size: 1.5em; padding: .5em; @@ -91,9 +84,20 @@ button.honking { box-shadow: 0.2em 0.2em 0.3em #888888; position: relative; } -button.honking:hover { +.honking:hover { box-shadow: none; top: .1em; left: .1em; - +} + + + +.share { + a { + margin-right: 1.5em; + + img { + vertical-align: middle; + } + } } diff --git a/apps/funding/templates/funding/offer_detail.html b/apps/funding/templates/funding/offer_detail.html index f3484ed16..da50f13a7 100755 --- a/apps/funding/templates/funding/offer_detail.html +++ b/apps/funding/templates/funding/offer_detail.html @@ -3,10 +3,13 @@ {% load i18n %} {% load funding_tags %} {% load pagination_tags %} +{% load fnp_share %} {% block titleextra %}{{ object }}{% endblock %} +{% block metadescription %}Wesprzyj kolejną publikację Wolnych Lektur!{% endblock %} + {% block body %} @@ -16,8 +19,12 @@ {% funding object %}
+
{% offer_status object %} {% offer_status_more object %} +

{% trans "Learn more" %}.

+
+ {% if object.is_current %}
@@ -26,10 +33,18 @@ {% csrf_token %} {{ form.as_table }} - +
+ +
+ + {% url 'funding_current' object.slug as current %} +

{% trans "Tell your friends!" %}

+ {% endif %}

{% trans "See all fundraisers." %}

diff --git a/apps/funding/templates/funding/offer_list.html b/apps/funding/templates/funding/offer_list.html index f9b9d54fc..ffb6af000 100755 --- a/apps/funding/templates/funding/offer_list.html +++ b/apps/funding/templates/funding/offer_list.html @@ -22,7 +22,7 @@

{% trans "Previous fundraisers:" %}

{% endif %} -
+
{% offer_status offer %}
@@ -33,7 +33,6 @@ {% offer_status_more offer %}
-
{% if is_current and not forloop.is_last %}

{% trans "Previous fundraisers:" %}

{% endif %} diff --git a/apps/funding/templates/funding/tags/funding.html b/apps/funding/templates/funding/tags/funding.html index dbcb871df..c842f8ad5 100755 --- a/apps/funding/templates/funding/tags/funding.html +++ b/apps/funding/templates/funding/tags/funding.html @@ -4,21 +4,20 @@ {% spaceless %}
{% if link and is_current %} - + {% trans "Support a book!" %} {% endif %}
{% endspaceless %} diff --git a/apps/funding/templates/funding/tags/offer_status.html b/apps/funding/templates/funding/tags/offer_status.html index 998d942dc..24a5fcde7 100755 --- a/apps/funding/templates/funding/tags/offer_status.html +++ b/apps/funding/templates/funding/tags/offer_status.html @@ -2,23 +2,23 @@ {% if offer.is_current %} {% if offer.is_win %} -

+

{% blocktrans with due=offer.due end=offer.end %}The fundraiser ends on {{ end }}. The book will be published by {{ due }}.{% endblocktrans %}

{% else %} -

+

{% blocktrans with due=offer.due end=offer.end %}If the target is met by {{ end }}, this book will be published by {{ due }}.{% endblocktrans %}

{% endif %} {% else %} {% if offer.is_win %} -

+

{% trans "Full amount was successfully raised!" %}

{% else %} -

+

{% trans "The amount needed was not raised." %}

{% endif %} diff --git a/apps/funding/templates/funding/tags/offer_status_more.html b/apps/funding/templates/funding/tags/offer_status_more.html index 6291e9fb4..3ba0440ce 100755 --- a/apps/funding/templates/funding/tags/offer_status_more.html +++ b/apps/funding/templates/funding/tags/offer_status_more.html @@ -1,13 +1,13 @@ {% load i18n %} {% if offer.is_current %} -

+

{% include "funding/snippets/any_remaining.html" %}

{% else %} -

{{ offer.start }} – {{ offer.end }}

+

{{ offer.start }} – {{ offer.end }}

{% if offer.is_win %} -

+

{% if offer.book %} {% blocktrans with bu=offer.book.get_absolute_url bt=offer.book %}The book {{ bt }} has been already published.{% endblocktrans %} @@ -23,6 +23,6 @@ {% endif %} {% if offer.remaining %} -

{% include "funding/snippets/any_remaining.html" %}

+

{% include "funding/snippets/any_remaining.html" %}

{% endif %} {% endif %} diff --git a/apps/funding/templates/funding/thanks.html b/apps/funding/templates/funding/thanks.html index 72b7c2970..923ed666d 100755 --- a/apps/funding/templates/funding/thanks.html +++ b/apps/funding/templates/funding/thanks.html @@ -17,21 +17,22 @@

{% blocktrans with due=offer.due end=offer.end %}The fundraiser ends on {{ end }}. The book will be published by {{ due }}.{% endblocktrans %}

{% else %} -

{% blocktrans with b=object.title due=offer.due end=offer.end %}Your +

{% blocktrans with b=offer.title due=offer.due end=offer.end %}Your donation will be spent on publishing the book {{ b }} if the full amount is raised by {{ end }}. The book will then be published by {{ due }}.{% endblocktrans %}

{% endif %} -

{% include "funding/snippets/any_remaining.html" %}

+

{% include "funding/snippets/any_remaining.html" %} -{% url 'funding_current' as current %} +{% trans "Learn more" %}.

+ +{% url 'funding_current' offer.slug as current %}

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

{% trans "Tell your friends!" %}

- -

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

+ diff --git a/apps/funding/templates/funding/wlfund.html b/apps/funding/templates/funding/wlfund.html index 6a405ad56..b0b74f8bf 100755 --- a/apps/funding/templates/funding/wlfund.html +++ b/apps/funding/templates/funding/wlfund.html @@ -12,7 +12,10 @@ the full amount needed for publishing a book is not raised in time, the funds are spent on other books waiting for publication. The same thing happens with any money remaining -from successful fundraisers.{% endblocktrans %}

+from successful fundraisers.{% endblocktrans %} + +{% trans "Learn more" %}.

+

{% trans "Spending these remaining funds is recorded in this table." %}

@@ -30,18 +33,18 @@ from successful fundraisers.{% endblocktrans %}

{% if tag == 'spent' %}
{{ entry.timestamp }}
- {% trans "Money spent on publishing the book" %}: +
{% trans "Money spent on publishing the book" %}: - {{ entry.book }} + {{ entry.book }}
-{{ entry.amount }} zł
{{ entry.total }} zł
{% else %}
{{ entry.end }}
- {% trans "Money remaining from the fundraiser for" %}: +
{% trans "Money remaining from the fundraiser for" %}: - {{ entry }} + {{ entry }}
{{ entry.total }} zł
+{{ entry.wlfund }} zł
diff --git a/apps/funding/templatetags/funding_tags.py b/apps/funding/templatetags/funding_tags.py index d50551a38..bfac2654e 100755 --- a/apps/funding/templatetags/funding_tags.py +++ b/apps/funding/templatetags/funding_tags.py @@ -16,6 +16,7 @@ def funding(context, offer=None, link=False, add_class=""): 'offer': offer, 'sum': offer_sum, 'is_current': offer.is_current(), + 'is_win': offer_sum >= offer.target, 'missing': offer.target - offer_sum, 'percentage': 100 * offer_sum / offer.target, 'link': link, diff --git a/apps/funding/urls.py b/apps/funding/urls.py old mode 100755 new mode 100644 index 6b60035c3..eb9718038 --- a/apps/funding/urls.py +++ b/apps/funding/urls.py @@ -6,11 +6,13 @@ from django.conf.urls import patterns, url, include from .models import Offer from .views import (WLFundView, OfferDetailView, OfferListView, - ThanksView, NoThanksView) + ThanksView, NoThanksView, CurrentView) urlpatterns = patterns('', - url(r'^$', OfferDetailView.as_view(), name='funding_current'), + + url(r'^$', CurrentView.as_view(), name='funding_current'), + url(r'^teraz/(?P[^/]+)/$', CurrentView.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'^fundusz/$', WLFundView.as_view(), name='funding_wlfund'), diff --git a/apps/funding/views.py b/apps/funding/views.py index 66c34a28f..7bc822677 100644 --- a/apps/funding/views.py +++ b/apps/funding/views.py @@ -2,6 +2,7 @@ # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # +from datetime import date from django.views.decorators.cache import never_cache from django.conf import settings from django.core.urlresolvers import reverse @@ -51,13 +52,14 @@ class WLFundView(TemplateView): ctx = super(WLFundView, self).get_context_data() offers = [] - for o in Offer.objects.all(): - if o.state() == 'lose': - o.wlfund = o.sum() + + for o in Offer.past(): + if o.is_win(): + o.wlfund = o.sum() - o.target if o.wlfund > 0: offers.append(o) - elif o.state() == 'win': - o.wlfund = o.sum() - o.target + else: + o.wlfund = o.sum() if o.wlfund > 0: offers.append(o) amount = sum(o.wlfund for o in offers) - sum(o.amount for o in Spent.objects.all()) @@ -77,12 +79,13 @@ class OfferDetailView(FormView): backend = 'getpaid.backends.payu' def dispatch(self, request, slug=None): - if slug: - self.object = get_object_or_404(Offer.public(), slug=slug) - else: - self.object = Offer.current() - if self.object is None: - raise Http404 + if getattr(self, 'object', None) is None: + if slug: + self.object = get_object_or_404(Offer.public(), slug=slug) + else: + self.object = Offer.current() + if self.object is None: + raise Http404 return super(OfferDetailView, self).dispatch(request, slug) def get_form(self, form_class): @@ -102,9 +105,19 @@ class OfferDetailView(FormView): funding = form.save() # 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) + gateway_url_tuple = payment.get_processor()(payment).get_gateway_url(self.request) payment.change_status('in_progress') - return redirect(gateway_url) + return redirect(gateway_url_tuple[0]) + + +class CurrentView(OfferDetailView): + def dispatch(self, request, slug=None): + self.object = Offer.current() + if self.object is None: + raise Http404 + elif slug != self.object.slug: + return redirect(reverse('funding_current', args=[self.object.slug])) + return super(CurrentView, self).dispatch(request, slug) class OfferListView(ListView): diff --git a/apps/wolnelektury_core/static/img/social/bigfacebook.png b/apps/wolnelektury_core/static/img/social/bigfacebook.png new file mode 100644 index 000000000..630416cf2 Binary files /dev/null and b/apps/wolnelektury_core/static/img/social/bigfacebook.png differ diff --git a/apps/wolnelektury_core/static/img/social/biggoogle.png b/apps/wolnelektury_core/static/img/social/biggoogle.png new file mode 100644 index 000000000..19ad19df5 Binary files /dev/null and b/apps/wolnelektury_core/static/img/social/biggoogle.png differ diff --git a/apps/wolnelektury_core/static/img/social/bignk.png b/apps/wolnelektury_core/static/img/social/bignk.png new file mode 100644 index 000000000..c119cd117 Binary files /dev/null and b/apps/wolnelektury_core/static/img/social/bignk.png differ diff --git a/apps/wolnelektury_core/static/img/social/bigtwitter.png b/apps/wolnelektury_core/static/img/social/bigtwitter.png new file mode 100644 index 000000000..fafbe6412 Binary files /dev/null and b/apps/wolnelektury_core/static/img/social/bigtwitter.png differ diff --git a/requirements.txt b/requirements.txt index 784e85a10..836f6d309 100644 --- a/requirements.txt +++ b/requirements.txt @@ -55,4 +55,4 @@ pyoai egenix-mx-base sunburnt -django-getpaid +django-getpaid>=1.4,<1.5 diff --git a/wolnelektury/migrations/getpaid/0002_auto__add_field_payment_external_id__add_field_payment_description.py b/wolnelektury/migrations/getpaid/0002_auto__add_field_payment_external_id__add_field_payment_description.py new file mode 100644 index 000000000..c017e3ca8 --- /dev/null +++ b/wolnelektury/migrations/getpaid/0002_auto__add_field_payment_external_id__add_field_payment_description.py @@ -0,0 +1,106 @@ +# -*- 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 'Payment.external_id' + db.add_column(u'getpaid_payment', 'external_id', + self.gf('django.db.models.fields.CharField')(max_length=64, null=True, blank=True), + keep_default=False) + + # Adding field 'Payment.description' + db.add_column(u'getpaid_payment', 'description', + self.gf('django.db.models.fields.CharField')(max_length=128, null=True, blank=True), + keep_default=False) + + + def backwards(self, orm): + # Deleting field 'Payment.external_id' + db.delete_column(u'getpaid_payment', 'external_id') + + # Deleting field 'Payment.description' + db.delete_column(u'getpaid_payment', 'description') + + + 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'}), + 'description': ('django.db.models.fields.TextField', [], {'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'getpaid.payment': { + 'Meta': {'ordering': "('-created_on',)", 'object_name': 'Payment'}, + 'amount': ('django.db.models.fields.DecimalField', [], {'max_digits': '20', 'decimal_places': '4'}), + 'amount_paid': ('django.db.models.fields.DecimalField', [], {'default': '0', 'max_digits': '20', 'decimal_places': '4'}), + 'backend': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'created_on': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}), + 'currency': ('django.db.models.fields.CharField', [], {'max_length': '3'}), + 'description': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), + 'external_id': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'order': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'payment'", 'to': u"orm['funding.Funding']"}), + 'paid_on': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True', 'db_index': 'True', 'blank': 'True'}), + 'status': ('django.db.models.fields.CharField', [], {'default': "'new'", 'max_length': '20', 'db_index': 'True'}) + } + } + + complete_apps = ['getpaid'] \ No newline at end of file diff --git a/wolnelektury/settings/__init__.py b/wolnelektury/settings/__init__.py index 8403688a4..1ff9e0ef1 100644 --- a/wolnelektury/settings/__init__.py +++ b/wolnelektury/settings/__init__.py @@ -71,7 +71,6 @@ INSTALLED_APPS_OUR = [ ] GETPAID_BACKENDS = ( - 'getpaid.backends.dummy', 'getpaid.backends.payu', ) @@ -97,7 +96,6 @@ INSTALLED_APPS_CONTRIB = [ #'django_nose', 'fnpdjango', 'getpaid', - 'getpaid.backends.dummy', 'getpaid.backends.payu', #allauth stuff