class BookDetails(object):
"""Custom fields used for representing Books."""
- @classmethod
- def author(cls, book):
- return ",".join(t[0] for t in book.related_info()['tags'].get('author', []))
-
@classmethod
def href(cls, book):
""" Returns an URI for a Book in the API. """
"""
allowed_methods = ('GET',)
model = Book
- fields = ['author', 'href', 'title', 'url', 'cover']
+ fields = book_tag_categories + ['href', 'title', 'url', 'cover', 'cover_thumb']
+
+ @classmethod
+ def genres(cls, book):
+ """ Returns all media for a book. """
+ return book.tags.filter(category='genre')
@piwik_track
def read(self, request, tags, top_level=False,
class BooksHandler(BookDetailHandler):
allowed_methods = ('GET', 'POST')
model = Book
- fields = ['author', 'href', 'title', 'url']
+ fields = book_tag_categories + ['href', 'title', 'url', 'cover', 'cover_thumb']
anonymous = AnonymousBooksHandler
def create(self, request, *args, **kwargs):
def get_tags(cls, book):
return book.tags.filter(category=category)
return get_tags
+def _tag_getter(category):
+ @classmethod
+ def get_tag(cls, book):
+ return ", ".join(t[0] for t in book.related_info()['tags'].get(category, []))
+ return get_tag
for plural, singular in category_singular.items():
setattr(BookDetails, plural, _tags_getter(singular))
+ setattr(BookDetails, singular, _tag_getter(singular))
# add fields for files in Book
def _file_getter(format):
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-06-19 14:10+0200\n"
-"PO-Revision-Date: 2013-06-19 14:10+0100\n"
+"POT-Creation-Date: 2013-08-07 12:31+0200\n"
+"PO-Revision-Date: 2013-08-07 12:32+0100\n"
"Last-Translator: Radek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
msgid "Download custom PDF"
msgstr "Stwórz własny PDF"
-#: views.py:557 templates/catalogue/book_short.html:92
+#: views.py:557 templates/catalogue/book_short.html:96
#: templates/catalogue/book_text.html:27 templates/catalogue/book_wide.html:63
msgid "Download"
msgstr "Pobierz"
"Możecie z niej korzystać bezpłatnie i bez ograniczeń.\n"
"Audiobooki nagrywają znani aktorzy, wśród nich Danuta Stenka i Jan Peszek."
-#: templates/catalogue/book_detail.html:20
+#: templates/catalogue/book_detail.html:21
#: templates/catalogue/tagged_object_list.html:74
#: templates/catalogue/tagged_object_list.html:104
msgid "See also"
"Commons Attribution-ShareAlike 3.0</a>\n"
" license."
msgstr ""
-"Ten utwór nie jest chroniony prawem autorskim i znajduje się w "
+"Ten utwór nie jest objęty majątkowym prawem autorskim i znajduje się w "
"domenie publicznej, co oznacza że możesz go swobodnie wykorzystywać, "
"publikować i rozpowszechniać. Jeśli utwór opatrzony jest dodatkowymi "
"materiałami (przypisy, motywy literackie etc.), które podlegają prawu "
msgstr "Opracowanie redakcyjne i przypisy:"
#: templates/catalogue/book_info.html:33
+msgid "Publication funded by:"
+msgstr "Publikację ufundowali i ufundowały:"
+
+#: templates/catalogue/book_info.html:41
msgid "Cover image by:"
msgstr "Ilustracja na okładce:"
msgid "Table of Content"
msgstr "Spis treści"
-#: templates/catalogue/book_list.html:30
+#: templates/catalogue/book_list.html:31
msgid "↑ top ↑"
msgstr "↑ góra ↑"
-#: templates/catalogue/book_short.html:59
+#: templates/catalogue/book_short.html:61
#: templates/catalogue/picture_detail.html:54
msgid "Epoch"
msgstr "Epoka"
-#: templates/catalogue/book_short.html:66
+#: templates/catalogue/book_short.html:69
#: templates/catalogue/picture_detail.html:60
msgid "Kind"
msgstr "Rodzaj"
-#: templates/catalogue/book_short.html:73
+#: templates/catalogue/book_short.html:77
msgid "Genre"
msgstr "Gatunek"
-#: templates/catalogue/book_short.html:88
+#: templates/catalogue/book_short.html:92
msgid "Read online"
msgstr "Czytaj online"
-#: templates/catalogue/book_short.html:95
+#: templates/catalogue/book_short.html:99
#: templates/catalogue/book_text.html:40
msgid "to print"
msgstr "do druku"
-#: templates/catalogue/book_short.html:98
+#: templates/catalogue/book_short.html:102
msgid "for an e-book reader"
msgstr "na czytnik e-booków"
-#: templates/catalogue/book_short.html:101
+#: templates/catalogue/book_short.html:105
#: templates/catalogue/book_text.html:46
msgid "for Kindle"
msgstr "na Kindle"
-#: templates/catalogue/book_short.html:104
+#: templates/catalogue/book_short.html:108
#: templates/catalogue/book_text.html:49
msgid "FictionBook"
msgstr "FictionBook"
-#: templates/catalogue/book_short.html:107
+#: templates/catalogue/book_short.html:111
#: templates/catalogue/book_text.html:52
msgid "for advanced usage"
msgstr "do zadań specjalnych"
-#: templates/catalogue/book_short.html:113
+#: templates/catalogue/book_short.html:117
#: templates/catalogue/book_text.html:30
msgid "Listen"
msgstr "Słuchaj"
msgstr "Miksuj treść utworu"
#: templates/catalogue/catalogue.html:6 templates/catalogue/catalogue.html:11
+#: templates/catalogue/menu.html:5
msgid "Catalogue"
msgstr "Katalog"
msgid "Themes and topics"
msgstr "Motywy i tematy"
-#: templates/catalogue/catalogue.html:34 templates/catalogue/menu.html:16
+#: templates/catalogue/catalogue.html:34 templates/catalogue/menu.html:20
msgid "Collections"
msgstr "Kolekcje"
msgid "See full category"
msgstr "Zobacz całą kategorię"
-#: templates/catalogue/menu.html:9 templates/catalogue/menu.html.py:18
+#: templates/catalogue/menu.html:4
+msgid "Catalogue of the library"
+msgstr ""
+
+#: templates/catalogue/menu.html:13 templates/catalogue/menu.html.py:22
msgid "Please wait…"
msgstr "Proszę czekać…"
-#: templates/catalogue/menu.html:24
+#: templates/catalogue/menu.html:28
msgid "All books"
msgstr "Wszystkie utwory"
-#: templates/catalogue/menu.html:28
+#: templates/catalogue/menu.html:32
msgid "Audiobooks"
msgstr "Audiobooki"
-#: templates/catalogue/menu.html:32
+#: templates/catalogue/menu.html:36
msgid "DAISY"
msgstr "DAISY"
self.sort_key = sortify(self.title)
- ret = super(Book, self).save(force_insert, force_update)
+ ret = super(Book, self).save(force_insert, force_update, **kwargs)
if reset_short_html:
self.reset_short_html()
"""
# get relevant books and their tags
objects = cls.tagged.with_all(tags)
+ parents = objects.filter(html_file='').only('slug')
# eliminate descendants
l_tags = Tag.objects.filter(category='book',
- slug__in=[book.book_tag_slug() for book in objects.iterator()])
- descendants_keys = [book.pk for book in cls.tagged.with_any(l_tags).iterator()]
+ slug__in=[book.book_tag_slug() for book in parents.iterator()])
+ descendants_keys = [book.pk for book in cls.tagged.with_any(l_tags).only('pk').iterator()]
if descendants_keys:
objects = objects.exclude(pk__in=descendants_keys)
pre_delete.connect(_pre_delete_handler)
+def _post_delete_handler(sender, instance, **kwargs):
+ """ refresh Book on BookMedia delete """
+ if sender == Collection:
+ permanent_cache.delete('catalogue.collection:%s' % instance.slug)
+ permanent_cache.delete('catalogue.catalogue')
+post_delete.connect(_post_delete_handler)
+
+
def _post_save_handler(sender, instance, **kwargs):
""" refresh all the short_html stuff on BookMedia update """
if sender == BookMedia:
'catalogue.audiobook_list', 'catalogue.daisy_list'])
elif sender == Collection:
permanent_cache.delete('catalogue.collection:%s' % instance.slug)
+ permanent_cache.delete('catalogue.catalogue')
post_save.connect(_post_save_handler)
""" remove the book from search index, when it is deleted."""
import search
idx = search.Index()
- idx.open(timeout=10000) # 10 seconds timeout.
- try:
- idx.remove_book(instance)
- idx.index_tags()
- finally:
- idx.close()
+ idx.remove_book(instance)
+ idx.index_tags()
{% all_editors book.extra_info %}.</p>
{% endif %}
+{% if book.extra_info.funders %}
+ <p>{% trans "Publication funded by:" %}
+ {% for funder in book.extra_info.funders %}{{ funder }}{% if not forloop.last %}, {% else %}.{% endif %}{% endfor %}
+ </p>
+{% endif %}
+
{% if book.extra_info.cover_by %}
<p>{% trans "Cover image by:" %}
<a href="{{ book.extra_info.cover_source }}">
# get related tags from `tag_counter` and `theme_counter`
related_counts = {}
tags_pks = [tag.pk for tag in tags]
- for book in objects.iterator():
+ for book in objects:
for tag_pk, value in itertools.chain(book.tag_counter.iteritems(), book.theme_counter.iteritems()):
if tag_pk in tags_pks:
continue
{% blocktrans count object_list.count as c %}{{c}} footnote found{% plural %}{{c}} footnotes found{% endblocktrans %}
</p>
-{% if object_list %}
+{% if object_list.exists %}
{% autopaginate object_list 100 %}
{% paginate %}
+# -*- coding: utf-8 -*-
+# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
+from django.conf import settings as settings
+from catalogue.utils import AppSettings
+
+
+class Settings(AppSettings):
+ """Default settings for funding app."""
+ DEFAULT_LANGUAGE = u'pl'
+ DEFAULT_AMOUNT = 20
+ MIN_AMOUNT = 1
+ DAYS_NEAR = 2
+
+
+app_settings = Settings('FUNDING')
+# -*- coding: utf-8 -*-
+# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
+from django.utils.translation import ugettext_lazy as _
from django.contrib import admin
from .models import Offer, Perk, Funding, Spent
class OfferAdmin(admin.ModelAdmin):
model = Offer
- list_display = ['title', 'author', 'target', 'sum', 'is_win', 'start', 'end', 'due']
+ list_display = ['title', 'author', 'target', 'sum', 'is_win', 'start', 'end']
search_fields = ['title', 'author']
readonly_fields = ('cover_img_tag',)
class PerkAdmin(admin.ModelAdmin):
model = Perk
+ search_fields = ['name', 'long_name']
list_display = ['name', 'long_name', 'price', 'end_date', 'offer']
+ list_filter = ['offer']
+
+
+
+class PayedFilter(admin.SimpleListFilter):
+ title = _('payment complete')
+ parameter_name = 'payed'
+ def lookups(self, request, model_admin):
+ return (
+ ('yes', _('Yes')),
+ ('no', _('No')),
+ )
+ def queryset(self, request, queryset):
+ if self.value() == 'yes':
+ return queryset.exclude(payed_at=None)
+ elif self.value() == 'no':
+ return queryset.filter(payed_at=None)
+
+class PerksFilter(admin.SimpleListFilter):
+ title = _('perks')
+ parameter_name = 'perks'
+ def lookups(self, request, model_admin):
+ return (
+ ('yes', _('Yes')),
+ ('no', _('No')),
+ )
+ def queryset(self, request, queryset):
+ if self.value() == 'yes':
+ return queryset.exclude(perks=None)
+ elif self.value() == 'no':
+ return queryset.filter(perks=None)
class FundingAdmin(admin.ModelAdmin):
model = Funding
- list_display = ['payed_at', 'offer', 'amount', 'name', 'email']
+ list_display = ['payed_at', 'offer', 'amount', 'name', 'email', 'perk_names']
search_fields = ['name', 'email', 'offer__title', 'offer__author']
+ list_filter = [PayedFilter, 'offer', PerksFilter]
+
class SpentAdmin(admin.ModelAdmin):
-from django.conf import settings
+# -*- coding: utf-8 -*-
+# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
from django import forms
from django.utils import formats
from django.utils.translation import ugettext_lazy as _, ugettext, get_language
from .models import Funding
from .widgets import PerksAmountWidget
+from . import app_settings
class FundingForm(forms.Form):
name = forms.CharField(label=_("Name"), required=False,
help_text=_("Optional name for public list of contributors"))
email = forms.EmailField(label=_("Contact e-mail"),
- help_text=_("We'll use it to contact you about your perks and fundraiser status and payment updates.<br/> "
- "Won't be publicised."), required=False)
+ help_text=_("We'll use it to contact you about the <strong>details needed for your perks</strong>,<br/>"
+ "and to send you updates about your payment and the fundraiser status (which you can always turn off).<br/>"
+ "Your e-mail won't be publicised."), required=False)
def __init__(self, offer, *args, **kwargs):
self.offer = offer
self.fields['amount'].widget.form_instance = self
def clean_amount(self):
- if self.cleaned_data['amount'] < settings.FUNDING_MIN_AMOUNT:
- min_amount = settings.FUNDING_MIN_AMOUNT
- if isinstance(settings.FUNDING_MIN_AMOUNT, float):
- min_amount = formats.number_format(settings.FUNDING_MIN_AMOUNT, 2)
+ if self.cleaned_data['amount'] < app_settings.MIN_AMOUNT:
+ min_amount = app_settings.MIN_AMOUNT
+ if isinstance(min_amount, float):
+ min_amount = formats.number_format(min_amount, 2)
raise forms.ValidationError(
ugettext("The minimum amount is %(amount)s PLN.") % {
'amount': min_amount})
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-06-26 15:26+0200\n"
-"PO-Revision-Date: 2013-06-26 15:32+0100\n"
+"POT-Creation-Date: 2013-08-02 14:02+0200\n"
+"PO-Revision-Date: 2013-08-02 14:00+0100\n"
"Last-Translator: Radek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"|| n%100>=20) ? 1 : 2);\n"
"X-Generator: Poedit 1.5.4\n"
-#: forms.py:12 templates/funding/wlfund.html:27
+#: admin.py:26
+msgid "payment complete"
+msgstr "płatność doszła do skutku"
+
+#: admin.py:30 admin.py:44
+msgid "Yes"
+msgstr "Tak"
+
+#: admin.py:31 admin.py:45
+msgid "No"
+msgstr "Nie"
+
+#: admin.py:40 models.py:197 models.py:215
+msgid "perks"
+msgstr "prezenty"
+
+#: forms.py:16 templates/funding/wlfund.html:27
msgid "Amount"
msgstr "Kwota"
-#: forms.py:14
+#: forms.py:18
msgid "Name"
msgstr "Imię i nazwisko na listę darczyńców"
-#: forms.py:15
+#: forms.py:19
msgid "Optional name for public list of contributors"
-msgstr "Opcjonalnie imię i nazwisko lub pseudonim do listy darczyńców."
+msgstr ""
+"Opcjonalnie imię i nazwisko lub pseudonim do publicznej listy darczyńców."
-#: forms.py:16
+#: forms.py:20
msgid "Contact e-mail"
msgstr "E-mail kontaktowy"
-#: forms.py:17
+#: forms.py:21
msgid ""
-"We'll use it to contact you about your perks and fundraiser status and "
-"payment updates.<br/> Won't be publicised."
+"We'll use it to contact you about the <strong>details needed for your perks</"
+"strong>,<br/>and to send you updates about your payment and the fundraiser "
+"status (which you can always turn off).<br/>Your e-mail won't be publicised."
msgstr ""
-"Użyjemy go do kontaktu w sprawie prezentów i informacji o zmianach statusu "
-"zbiórki i kolejnych akcjach.<br/>Nie będzie publikowany."
+"Użyjemy go do kontaktu w sprawie <strong>danych potrzebnych do realizacji "
+"prezentów</strong><br/>i do informowania Cię o zmianach statusu płatności i "
+"zbiórki (z czego zawsze możesz zrezygnować).<br/>Twój adres e-mail nie "
+"będzie upubliczniony."
-#: forms.py:28
+#: forms.py:36
#, python-format
msgid "The minimum amount is %(amount)s PLN."
msgstr "Minimalna kwota wpłaty to %(amount)s zł."
-#: forms.py:34
+#: forms.py:42
msgid "This offer is out of date."
msgstr "Ta zbiórka jest już nieaktywna."
-#: models.py:19
+#: models.py:23
msgid "author"
msgstr "autor"
-#: models.py:20
+#: models.py:24
msgid "title"
msgstr "tytuł"
-#: models.py:21
+#: models.py:25
msgid "slug"
msgstr "slug"
-#: models.py:22
+#: models.py:26
msgid "description"
msgstr "opis"
-#: models.py:23
+#: models.py:27
msgid "target"
msgstr "kwota docelowa"
-#: models.py:24
+#: models.py:28
msgid "start"
msgstr "początek"
-#: models.py:25
+#: models.py:29
msgid "end"
msgstr "koniec"
-#: models.py:26
-msgid "due"
-msgstr "data publikacji"
-
-#: models.py:27
-msgid "When will it be published if the money is raised."
-msgstr "Kiedy książka zostanie opublikowana, jeśli uda się zebrać pieniądze."
-
-#: models.py:28
+#: models.py:30
msgid "redakcja URL"
msgstr "URL na Redakcji"
-#: models.py:30
+#: models.py:32
msgid "Published book."
msgstr "Opublikowana książka."
-#: models.py:31
+#: models.py:33
msgid "Cover"
msgstr "Okładka"
-#: models.py:32
+#: models.py:34
msgid "Poll"
msgstr "Ankieta"
#: models.py:36
+msgid "Near-end notifications sent"
+msgstr "Wysłano powiadomienia przed końcem"
+
+#: models.py:37
+msgid "End notifications sent"
+msgstr "Wysłano powiadomienia o zakończeniu"
+
+#: models.py:41
msgid "Cover preview"
msgstr "Podgląd okładki"
-#: models.py:40 models.py:114 models.py:135
+#: models.py:45 models.py:189 models.py:210
msgid "offer"
msgstr "zbiórka"
-#: models.py:41
+#: models.py:46
msgid "offers"
msgstr "zbiórki"
-#: models.py:115
+#: models.py:144
+msgid "The fundraiser has ended!"
+msgstr "Zbiórka dobiegła końca!"
+
+#: models.py:160
+msgid "The fundraiser will end soon!"
+msgstr "Zbiórka niedługo się zakończy!"
+
+#: models.py:174
+msgid "The book you helped fund has been published."
+msgstr "Książka, którą pomogłeś/-aś ufundować, została opublikowana."
+
+#: models.py:190
msgid "price"
msgstr "cena"
-#: models.py:116 models.py:136
+#: models.py:191 models.py:211
msgid "name"
msgstr "nazwa"
-#: models.py:117
+#: models.py:192
msgid "long name"
msgstr "długa nazwa"
-#: models.py:118
+#: models.py:193
msgid "end date"
msgstr "data końcowa"
-#: models.py:121
+#: models.py:196
msgid "perk"
msgstr "prezent"
-#: models.py:122 models.py:140
-msgid "perks"
-msgstr "prezenty"
-
-#: models.py:137
+#: models.py:212
msgid "email"
msgstr "e-mail"
-#: models.py:138 models.py:168
+#: models.py:213 models.py:293
msgid "amount"
msgstr "kwota"
-#: models.py:139
+#: models.py:214
msgid "payed at"
msgstr "data wpłaty"
-#: models.py:151
+#: models.py:217
+msgid "notifications"
+msgstr "powiadomienia"
+
+#: models.py:221
msgid "funding"
msgstr "wpłata"
-#: models.py:152
+#: models.py:222 templates/admin/funding/offer/change_form.html:22
msgid "fundings"
msgstr "wpłaty"
-#: models.py:169
+#: models.py:294
msgid "when"
msgstr "kiedy"
-#: models.py:172
+#: models.py:297
msgid "money spent on a book"
msgstr "pieniądze wydane na książkę"
-#: models.py:173
+#: models.py:298
msgid "money spent on books"
msgstr "pieniądze wydane na książki"
-#: models.py:203 templates/funding/thanks.html:6
+#: models.py:324 templates/funding/thanks.html:6
#: templates/funding/thanks.html.py:13
msgid "Thank you for your support!"
msgstr "Dziękujemy za Twoje wsparcie!"
-#: templates/funding/email.txt:3
-msgid "Hi"
-msgstr "Cześć"
-
-#: templates/funding/email.txt:5
-msgid ""
-"Thank you for your support - thanks to you we will set another book free."
-msgstr "Dziękujemy za wsparcie - dzięki Tobie uwolnimy kolejną książkę."
+#: templates/funding/disable_notifications.html:5
+#: templates/funding/no_thanks.html:5 templates/funding/no_thanks.html.py:9
+msgid "Payment failed"
+msgstr "Płatność nie doszła do skutku"
-#: templates/funding/email.txt:7
-msgid "The book will be supplemented with your name as a donor."
-msgstr ""
-"Twoje imię i nazwisko lub pseudonim zostaną dodane do listy darczyńców przy "
-"opublikowanej książce."
+#: templates/funding/disable_notifications.html:9
+#: templates/funding/disable_notifications.html:16
+msgid "Disable notifications"
+msgstr "Wyłącz powiadomienia"
-#: templates/funding/email.txt:9
-msgid ""
-"We will contact you to keep you informed about your perks,\n"
-"status changes to this fundraiser and the incoming ones that we plan to "
-"launch."
-msgstr ""
-"Skontaktujemy się Tobą w sprawie prezentów i informacji o zmianach statusu "
-"zbiórki oraz kolejnych akcjach."
+#: templates/funding/disable_notifications.html:14
+#, python-format
+msgid "Are you sure you want to disable notifications for address %(e)s?"
+msgstr "Czy na pewno chcesz wyłączyć powiadomienia dla adresu %(e)s?"
-#: templates/funding/email.txt:12
-msgid ""
-"Cheers,\n"
-"Wolne Lektury team"
-msgstr ""
-"Pozdrawiamy,\n"
-"zespół Wolnych Lektur"
+#: templates/funding/disable_notifications.html:21
+#, python-format
+msgid "Notifications for address %(e)s have been successfully disabled."
+msgstr "Powiadomienia dla adresu %(e)s zostały wyłączone."
-#: templates/funding/no_thanks.html:5 templates/funding/no_thanks.html.py:9
-msgid "Payment failed"
-msgstr "Płatność nie doszła do skutku"
+#: templates/funding/disable_notifications.html:27
+#, python-format
+msgid "Return to the <a href=\"%(current)s\">current fundraiser</a>."
+msgstr "Wróć do <a href=\"%(current)s\">aktualnej zbiórki</a>."
#: templates/funding/no_thanks.html:12
msgid "You're support has not been processed successfully."
"Wróć do <a href=\"%(current)s\">aktualnej zbiórki</a> i spróbuj ponownie lub "
"użyj innej metody płatności."
-#: templates/funding/offer_detail.html:32 templates/funding/offer_list.html:29
+#: templates/funding/offer_detail.html:32 templates/funding/offer_list.html:31
#: templates/funding/tags/funding.html:20
#: templates/funding/tags/funding.html:46
msgid "Help free the book!"
msgstr "Pomóż uwolnić książkę!"
-#: templates/funding/offer_detail.html:36 templates/funding/thanks.html:29
+#: templates/funding/offer_detail.html:36 templates/funding/thanks.html:33
#: templates/funding/wlfund.html:17 templates/funding/tags/funding.html:12
msgid "Learn more"
msgstr "Dowiedz się więcej"
msgid "Support the publication"
msgstr "Wesprzyj publikację"
-#: templates/funding/offer_detail.html:51
+#: templates/funding/offer_detail.html:50
msgid "Donate!"
msgstr "Wpłać!"
-#: templates/funding/offer_detail.html:59 templates/funding/thanks.html:35
+#: templates/funding/offer_detail.html:58 templates/funding/thanks.html:39
msgid "Tell your friends!"
msgstr "Powiedz swoim znajomym!"
-#: templates/funding/offer_detail.html:60
+#: templates/funding/offer_detail.html:59
msgid "Support Wolne Lektury!"
msgstr "Wesprzyj Wolne Lektury!"
-#: templates/funding/offer_detail.html:63
+#: templates/funding/offer_detail.html:62
msgid "See all fundraisers."
msgstr "Zobacz wszystkie zbiórki."
-#: templates/funding/offer_detail.html:68
+#: templates/funding/offer_detail.html:67
msgid "Supporters"
msgstr "Wpłaty"
-#: templates/funding/offer_detail.html:82
+#: templates/funding/offer_detail.html:81
msgid "Anonymous"
msgstr "Anonim"
msgid "All fundraisers"
msgstr "Wszystkie zbiórki"
-#: templates/funding/offer_list.html:20
+#: templates/funding/offer_list.html:17
msgid "Current fundraiser:"
msgstr "Aktualna zbiórka:"
-#: templates/funding/offer_list.html:22 templates/funding/offer_list.html:37
+#: templates/funding/offer_list.html:23
+msgid "No fundraiser is currently running."
+msgstr "Obecnie nie jest aktywna żadna zbiórka."
+
+#: templates/funding/offer_list.html:24 templates/funding/offer_list.html:39
msgid "Previous fundraisers:"
msgstr "Poprzednie zbiórki:"
msgid "Thank you!"
msgstr "Dziękujemy!"
-#: templates/funding/thanks.html:16
-#: templates/funding/tags/offer_status.html:22
+#: templates/funding/thanks.html:14
+msgid "We will contact you if you qualify for perks."
+msgstr "Skontaktujemy się z Tobą w sprawie prezentów, które wybrałeś/-aś."
+
+#: templates/funding/thanks.html:17
+#: templates/funding/tags/offer_status.html:24
msgid "Full amount was successfully raised!"
msgstr "Udało się zebrać pełną kwotę!"
-#: templates/funding/thanks.html:18 templates/funding/tags/offer_status.html:6
+#: templates/funding/thanks.html:19
#, python-format
msgid ""
-"The fundraiser\n"
-" ends on %(end)s. The book will be published by %(due)s."
-msgstr "Zbiórka kończy się %(end)s. Książka zostanie opublikowana do %(due)s."
+"Your donation will be spent on digitizing, compiling and\n"
+" publishing the book %(b)s in multiple formats."
+msgstr ""
+"Wpłacone przez Ciebie pieniądze przeznaczymy na digitalizację, opracowanie i "
+"udostępnienie książki %(b)s w bibliotece w wielu formatach."
-#: templates/funding/thanks.html:22
+#: templates/funding/thanks.html:24
#, python-format
msgid ""
-"Your donation will be spent on digitizing, compiling and\n"
-" publishing the book %(b)s in multiple formats. We will contact you "
-"if you qualify for perks."
+"If the full amount needed is raised,\n"
+" your donation will be spent on digitizing, compiling and\n"
+" publishing the book %(b)s in multiple formats."
msgstr ""
-"Pieniądze przez Ciebie wpłacone przeznaczymy na digitalizację, opracowanie "
-"i udostępnienie książki %(b)s w serwisie w wielu formatach. Jeśli wybrałeś/-"
-"aś nagrody, skontaktujemy się z Tobą mailowo."
+"Jeśli uda się zebrać pełną kwotę, wpłacone przez Ciebie pieniądze "
+"przeznaczymy na digitalizację, opracowanie i udostępnienie książki %(b)s w "
+"bibliotece w wielu formatach."
-#: templates/funding/thanks.html:32
+#: templates/funding/thanks.html:36
msgid "Go back to the current fundraiser."
msgstr "Wróć do aktualnej zbiórki."
-#: templates/funding/thanks.html:36
+#: templates/funding/thanks.html:40
msgid "I support Wolne Lektury."
msgstr "Wspieram Wolne Lektury"
-#: templates/funding/thanks.html:39
+#: templates/funding/thanks.html:43
msgid "Vote for a book for the next fundraiser"
msgstr "Pomóż wybrać następną książkę, na którą będziemy zbierać pieniądze"
msgid "Money remaining from the fundraiser for"
msgstr "Pieniądze pozostałe ze zbiórki na"
+#: templates/funding/wlfund.html:53
+msgid "There are no previous fundraisers to show yet."
+msgstr "Nie ma jeszcze żadnych zakończonych zbiórek."
+
+#: templates/funding/email/base.txt:1
+msgid "Hi"
+msgstr "Cześć"
+
+#: templates/funding/email/base.txt:4
+msgid ""
+"Cheers,\n"
+"Wolne Lektury team"
+msgstr ""
+"Pozdrawiamy\n"
+"zespół Wolnych Lektur"
+
+#: templates/funding/email/base.txt:8
+msgid "If you don't want to receive any more updates, please visit this page:"
+msgstr "Jeśli nie chcesz otrzymywać kolejnych powiadomień, odwiedź tę stronę:"
+
+#: templates/funding/email/end.txt:6
+msgid ""
+"we succesfully collected the full amount needed\n"
+"for the book you contributed to:"
+msgstr "udało nam się zebrać pełną kwotę na książkę, którą wsparłeś/-aś:"
+
+#: templates/funding/email/end.txt:12
+msgid ""
+"We will now digitize it, develop and publish it in the library,\n"
+"in various formats, free for everyone."
+msgstr ""
+"Teraz ją zdigitalizujemy, opracujemy i bezpłatnie udostępnimy w bibliotece w "
+"wielu formatach."
+
+#: templates/funding/email/end.txt:15
+msgid ""
+"Your name will be included on the list of contributors, irrespectively\n"
+"of the amount of your contribution."
+msgstr ""
+"Zostaniesz umieszczony/-a na liście darczyńców, niezależnie od wysokości "
+"wpłaty."
+
+#: templates/funding/email/end.txt:18
+msgid ""
+"We will contact you again about details needed\n"
+"to deliver your perks."
+msgstr "Skontaktujemy się z Tobą w sprawie prezentów, które wybrałeś/-aś."
+
+#: templates/funding/email/end.txt:21
+#, python-format
+msgid ""
+"All of the money remaining after this fundraiser (%(r)s PLN)\n"
+"will be spent on liberating other books still waiting for publication."
+msgstr ""
+"Wszystkie dodatkowe pieniądze pozostałe z tej zbiórki (%(r)s PLN)\n"
+"zostaną przeznaczone na uwolnienie innych książek czekających na publikację."
+
+#: templates/funding/email/end.txt:23 templates/funding/email/end.txt.py:34
+msgid "You can see how we're spending these funds on this page:"
+msgstr "Możesz zobaczyć, jak wydajemy te środki, na tej stronie:"
+
+#: templates/funding/email/end.txt:26
+msgid ""
+"unfortunately, we were unable to collect the full amount needed\n"
+"for the book you contributed to:"
+msgstr ""
+"niestety, nie udało nam się zebrać pełnej kwoty na książkę, którą wsparłeś/-"
+"aś:"
+
+#: templates/funding/email/end.txt:32
+#, python-format
+msgid ""
+"All of the money we collected in this fundraiser (%(x)s PLN)\n"
+"will be spent on liberating other books still waiting for publication."
+msgstr ""
+"Wszystkie pieniądze z tej zbiórki (%(x)s PLN)\n"
+"zostaną przeznaczone na uwolnienie innych książek czekających na publikację."
+
+#: templates/funding/email/end.txt:37 templates/funding/email/published.txt:12
+msgid ""
+"If you'd like to help liberate another book, or invite your friends\n"
+"to do so, we're currently raising money for:"
+msgstr ""
+"Jeśli chcesz pomóc uwolnić kolejną książkę, albo zachęcić do tego\n"
+"swoich znajomych, to aktualnie zbieramy na:"
+
+#: templates/funding/email/near.txt:5
+#, python-format
+msgid "there's only %(d)s day left until the end of the fundraiser for:\n"
+msgid_plural ""
+"There're only %(d)s days left until the end of the fundraiser for:\n"
+msgstr[0] "został jeden dzień do końca zbiórki na:\n"
+msgstr[1] "zostały %(d)s dni do końca zbiórki na:\n"
+msgstr[2] "zostało %(d)s dni do końca zbiórki na:\n"
+
+#: templates/funding/email/near.txt:10
+#, python-format
+msgid "We managed to collect %(x)s PLN so far."
+msgstr "Dotąd udało nam się zebrać %(x)s PLN."
+
+#: templates/funding/email/near.txt:12
+msgid ""
+"The fundraiser is a success already, but the more money\n"
+"we collect, the more other books we'll publish."
+msgstr ""
+"Zbiórka już osiągnęła sukces, ale im więcej pieniędzy\n"
+"zbierzemy, tym więcej opublikujemy książek."
+
+#: templates/funding/email/near.txt:14
+#, python-format
+msgid "We still need %(x)s PLN more."
+msgstr "Nadal potrzebujemy %(x)s PLN."
+
+#: templates/funding/email/near.txt:16
+msgid "There's still time to let your friends know about the fundraiser!"
+msgstr "Jest jeszcze czas, by poinformować o zbiórce Twoich znajomych!"
+
+#: templates/funding/email/published.txt:4
+msgid "we have just published the book you contributed to:"
+msgstr "właśnie opublikowaliśmy książkę, którą wsparłeś/-aś:"
+
+#: templates/funding/email/published.txt:9
+msgid ""
+"Thanks to you, it is now available for free,\n"
+"in various formats, to everyone."
+msgstr ""
+"Dzięki Tobie jest teraz dostępna bezpłatnie\n"
+"dla wszystkich w wielu formatach."
+
+#: templates/funding/email/thanks.txt:6
+msgid ""
+"Thank you for your support - thanks to you we will set another book free."
+msgstr "Dziękujemy za wsparcie - dzięki Tobie uwolnimy kolejną książkę."
+
+#: templates/funding/email/thanks.txt:8
+msgid "The book will be supplemented with your name as a donor."
+msgstr ""
+"Twoje imię i nazwisko lub pseudonim zostaną dodane do listy darczyńców przy "
+"opublikowanej książce."
+
+#: templates/funding/email/thanks.txt:10
+msgid "We will contact you about details needed for your perks."
+msgstr "Skontaktujemy się z Tobą w sprawie prezentów, które wybrałeś/-aś."
+
+#: templates/funding/email/thanks.txt:12
+msgid ""
+"We will keep you informed about status changes to this fundraiser\n"
+"and the upcoming ones that we plan to launch."
+msgstr ""
+"Będziemy Cię informować o zmianach statusu tej zbiórki\n"
+"i o kolejnych, które planujemy rozpocząć."
+
#: templates/funding/snippets/any_remaining.html:4
#, python-format
msgid ""
msgid "until fundraiser end"
msgstr "do końca zbiórki"
-#: templates/funding/tags/offer_status.html:11
+#: templates/funding/tags/offer_status.html:6
+#, python-format
+msgid ""
+"The fundraiser\n"
+" ends on %(end)s. The full amount has been successfully\n"
+" raised, but you can still contribute and help liberate\n"
+" more books."
+msgstr ""
+"Zbiórka kończy się %(end)s. Pełna kwota została już zebrana,\n"
+" ale ciągle możesz dołożyć się i pomóc uwolnić więcej książek."
+
+#: templates/funding/tags/offer_status.html:13
#, python-format
msgid ""
"W need %(target)s zł to digitize it,\n"
"Potrzebujemy %(target)s zł, by ją zdigitalizować, opracować i bezpłatnie "
"udostępnić w serwisie w wielu formatach."
-#: templates/funding/tags/offer_status.html:15
+#: templates/funding/tags/offer_status.html:17
#, python-format
msgid ""
"If we raise enought money before %(end)s we will\n"
"Jeśli do %(end)s uda się zebrać pełną kwotę, opublikujemy ją i będzie "
"dostępna dla wszystkich."
-#: templates/funding/tags/offer_status.html:26
+#: templates/funding/tags/offer_status.html:28
msgid "The amount needed was not raised."
msgstr "Nie udało się zebrać pełnej kwoty."
"Książka\n"
" <a href=\"%(bu)s\">%(bt)s</a> została opublikowana."
-#: templates/funding/tags/offer_status_more.html:15
-#, python-format
-msgid ""
-"The book\n"
-" will be published by %(due)s."
-msgstr "Książka zostanie opublikowana do %(due)s."
-
-#: templates/funding/tags/offer_status_more.html:18
+#: templates/funding/tags/offer_status_more.html:16
#, python-format
msgid ""
"You can follow\n"
#: templates/funding/widgets/amount.html:13
msgid "Other amount"
msgstr "Inna kwota"
+
+#~ msgid "due"
+#~ msgstr "data publikacji"
+
+#~ msgid "When will it be published if the money is raised."
+#~ msgstr ""
+#~ "Kiedy książka zostanie opublikowana, jeśli uda się zebrać pieniądze."
+
+#~ msgid ""
+#~ "The fundraiser\n"
+#~ " ends on %(end)s. The book will be published by %(due)s."
+#~ msgstr ""
+#~ "Zbiórka kończy się %(end)s. Książka zostanie opublikowana do %(due)s."
+
+#~ msgid ""
+#~ "The book\n"
+#~ " will be published by %(due)s."
+#~ msgstr "Książka zostanie opublikowana do %(due)s."
--- /dev/null
+# -*- coding: utf-8 -*-
+# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
+from optparse import make_option
+from django.core.management.base import BaseCommand
+
+
+class Command(BaseCommand):
+ option_list = BaseCommand.option_list + (
+ make_option('-q', '--quiet', action='store_false', dest='verbose', default=True,
+ help='Suppress output'),
+ )
+ help = 'Sends relevant funding notifications.'
+
+ def handle(self, **options):
+
+ from datetime import date, timedelta
+ from funding.models import Offer
+ from funding import app_settings
+
+ verbose = options['verbose']
+
+ for offer in Offer.past().filter(notified_end=None):
+ if verbose:
+ print 'Notify end:', offer
+ offer.notify_end()
+
+ current = Offer.current()
+ if (current is not None and
+ current.end <= date.today() + timedelta(app_settings.DAYS_NEAR - 1) and
+ not current.notified_near):
+ if verbose:
+ print 'Notify near:', current
+ current.notify_near()
--- /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 'Funding.notifications'
+ db.add_column(u'funding_funding', 'notifications',
+ self.gf('django.db.models.fields.BooleanField')(default=True, db_index=True),
+ keep_default=False)
+
+ # Adding field 'Funding.notify_key'
+ db.add_column(u'funding_funding', 'notify_key',
+ self.gf('django.db.models.fields.CharField')(default='x', max_length=32),
+ keep_default=False)
+
+ # Adding index on 'Funding', fields ['email']
+ db.create_index(u'funding_funding', ['email'])
+
+
+ def backwards(self, orm):
+ # Removing index on 'Funding', fields ['email']
+ db.delete_index(u'funding_funding', ['email'])
+
+ # Deleting field 'Funding.notifications'
+ db.delete_column(u'funding_funding', 'notifications')
+
+ # Deleting field 'Funding.notify_key'
+ db.delete_column(u'funding_funding', 'notify_key')
+
+
+ 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', [], {'db_index': 'True', 'max_length': '75', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language_code': ('django.db.models.fields.CharField', [], {'max_length': '2', 'null': 'True', 'blank': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '127', 'blank': 'True'}),
+ 'notifications': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}),
+ 'notify_key': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
+ 'offer': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['funding.Offer']"}),
+ 'payed_at': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', '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'}),
+ 'cover': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
+ 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'due': ('django.db.models.fields.DateField', [], {}),
+ 'end': ('django.db.models.fields.DateField', [], {'db_index': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'poll': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['polls.Poll']", 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': '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', [], {'db_index': 'True'}),
+ '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'},
+ 'end_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'long_name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ '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', [], {})
+ },
+ u'polls.poll': {
+ 'Meta': {'object_name': 'Poll'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'open': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'question': ('django.db.models.fields.TextField', [], {}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'})
+ }
+ }
+
+ 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):
+ # Deleting field 'Offer.due'
+ db.delete_column(u'funding_offer', 'due')
+
+
+ def backwards(self, orm):
+
+ # User chose to not deal with backwards NULL issues for 'Offer.due'
+ raise RuntimeError("Cannot reverse this migration. 'Offer.due' and its values cannot be restored.")
+
+ 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', [], {'db_index': 'True', 'max_length': '75', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language_code': ('django.db.models.fields.CharField', [], {'max_length': '2', 'null': 'True', 'blank': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '127', 'blank': 'True'}),
+ 'notifications': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}),
+ 'notify_key': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
+ 'offer': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['funding.Offer']"}),
+ 'payed_at': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', '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'}),
+ 'cover': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
+ 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'end': ('django.db.models.fields.DateField', [], {'db_index': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'poll': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['polls.Poll']", 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': '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', [], {'db_index': 'True'}),
+ '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'},
+ 'end_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'long_name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ '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', [], {})
+ },
+ u'polls.poll': {
+ 'Meta': {'object_name': 'Poll'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'open': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'question': ('django.db.models.fields.TextField', [], {}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'})
+ }
+ }
+
+ 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 'Offer.notified_near'
+ db.add_column(u'funding_offer', 'notified_near',
+ self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True),
+ keep_default=False)
+
+ # Adding field 'Offer.notified_end'
+ db.add_column(u'funding_offer', 'notified_end',
+ self.gf('django.db.models.fields.DateTimeField')(null=True, blank=True),
+ keep_default=False)
+
+
+ def backwards(self, orm):
+ # Deleting field 'Offer.notified_near'
+ db.delete_column(u'funding_offer', 'notified_near')
+
+ # Deleting field 'Offer.notified_end'
+ db.delete_column(u'funding_offer', 'notified_end')
+
+
+ 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', [], {'db_index': 'True', 'max_length': '75', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language_code': ('django.db.models.fields.CharField', [], {'max_length': '2', 'null': 'True', 'blank': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '127', 'blank': 'True'}),
+ 'notifications': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}),
+ 'notify_key': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
+ 'offer': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['funding.Offer']"}),
+ 'payed_at': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', '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'}),
+ 'cover': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
+ 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'end': ('django.db.models.fields.DateField', [], {'db_index': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'notified_end': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'notified_near': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'poll': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['polls.Poll']", 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': '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', [], {'db_index': 'True'}),
+ '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'},
+ 'end_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'long_name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ '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', [], {})
+ },
+ u'polls.poll': {
+ 'Meta': {'object_name': 'Poll'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'open': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'question': ('django.db.models.fields.TextField', [], {}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'})
+ }
+ }
+
+ complete_apps = ['funding']
\ No newline at end of file
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
from datetime import date, datetime
+from urllib import urlencode
from django.core.urlresolvers import reverse
from django.core.mail import send_mail
from django.conf import settings
from django.template.loader import render_to_string
from django.db import models
-from django.utils.translation import ugettext_lazy as _, ugettext as __, override
+from django.utils.translation import ugettext_lazy as _, ugettext, override
import getpaid
from catalogue.models import Book
+from catalogue.utils import get_random_hash
from polls.models import Poll
+from django.contrib.sites.models import Site
+from . import app_settings
class Offer(models.Model):
target = models.DecimalField(_('target'), decimal_places=2, max_digits=10)
start = models.DateField(_('start'), db_index=True)
end = models.DateField(_('end'), db_index=True)
- due = models.DateField(_('due'),
- help_text=_('When will it be published if the money is raised.'))
redakcja_url = models.URLField(_('redakcja URL'), blank=True)
book = models.ForeignKey(Book, null=True, blank=True,
help_text=_('Published book.'))
cover = models.ImageField(_('Cover'), upload_to = 'funding/covers')
poll = models.ForeignKey(Poll, help_text = _('Poll'), null = True, blank = True, on_delete = models.SET_NULL)
-
+
+ notified_near = models.DateTimeField(_('Near-end notifications sent'), blank=True, null=True)
+ notified_end = models.DateTimeField(_('End notifications sent'), blank=True, null=True)
+
def cover_img_tag(self):
return u'<img src="%s" />' % self.cover.url
cover_img_tag.short_description = _('Cover preview')
def get_absolute_url(self):
return reverse('funding_offer', args=[self.slug])
+ def save(self, *args, **kw):
+ published_now = (self.book_id is not None and
+ self.pk is not None and
+ type(self).objects.values('book').get(pk=self.pk)['book'] != self.book_id)
+ retval = super(Offer, self).save(*args, **kw)
+ if published_now:
+ self.notify_published()
+ return retval
+
def is_current(self):
- return self.start <= date.today() <= self.end
+ return self.start <= date.today() <= self.end and self == self.current()
def is_win(self):
return self.sum() >= self.target
@classmethod
def current(cls):
- """ Returns current fundraiser or None. """
+ """ Returns current fundraiser or None.
+
+ Current fundraiser is the one that:
+ - has already started,
+ - hasn't yet ended,
+ - if there's more than one of those, it's the one that ends last.
+
+ """
today = date.today()
- objects = cls.objects.filter(start__lte=today, end__gte=today)
+ objects = cls.objects.filter(start__lte=today, end__gte=today).order_by('-end')
try:
return objects[0]
except IndexError:
@classmethod
def past(cls):
- """ QuerySet for all current and past fundraisers. """
- today = date.today()
- return cls.objects.filter(end__lt=today)
+ """ QuerySet for all past fundraisers. """
+ objects = cls.public()
+ current = cls.current()
+ if current is not None:
+ objects = objects.exclude(pk=current.pk)
+ return objects
@classmethod
def public(cls):
""" QuerySet for all completed payments for the offer. """
return Funding.payed().filter(offer=self)
+ def funders(self):
+ return self.funding_payed().order_by('-amount', 'payed_at')
+
def sum(self):
""" The money gathered. """
return self.funding_payed().aggregate(s=models.Sum('amount'))['s'] or 0
+ def notify_all(self, subject, template_name, extra_context=None):
+ Funding.notify_funders(
+ subject, template_name, extra_context,
+ query_filter=models.Q(offer=self)
+ )
+
+ def notify_end(self, force=False):
+ if not force and self.notified_end: return
+ assert not self.is_current()
+ self.notify_all(
+ _('The fundraiser has ended!'),
+ 'funding/email/end.txt', {
+ 'offer': self,
+ 'is_win': self.is_win(),
+ 'remaining': self.remaining(),
+ 'current': self.current(),
+ })
+ self.notified_end = datetime.now()
+ self.save()
+
+ def notify_near(self, force=False):
+ if not force and self.notified_near: return
+ assert self.is_current()
+ sum_ = self.sum()
+ need = self.target - sum_
+ self.notify_all(
+ _('The fundraiser will end soon!'),
+ 'funding/email/near.txt', {
+ 'days': (self.end - date.today()).days + 1,
+ 'offer': self,
+ 'is_win': self.is_win(),
+ 'sum': sum_,
+ 'need': need,
+ })
+ self.notified_near = datetime.now()
+ self.save()
+
+ def notify_published(self):
+ assert self.book is not None
+ self.notify_all(
+ _('The book you helped fund has been published.'),
+ 'funding/email/published.txt', {
+ 'offer': self,
+ 'book': self.book,
+ 'author': ", ".join(a[0] for a in self.book.related_info()['tags']['author']),
+ 'current': self.current(),
+ })
+
class Perk(models.Model):
""" A perk offer.
"""
offer = models.ForeignKey(Offer, verbose_name=_('offer'))
name = models.CharField(_('name'), max_length=127, blank=True)
- email = models.EmailField(_('email'), blank=True)
+ email = models.EmailField(_('email'), blank=True, db_index=True)
amount = models.DecimalField(_('amount'), decimal_places=2, max_digits=10)
payed_at = models.DateTimeField(_('payed at'), null=True, blank=True, db_index=True)
perks = models.ManyToManyField(Perk, verbose_name=_('perks'), blank=True)
language_code = models.CharField(max_length = 2, null = True, blank = True)
+ notifications = models.BooleanField(_('notifications'), default=True, db_index=True)
+ notify_key = models.CharField(max_length=32)
- # Any additional info needed for perks?
+ class Meta:
+ verbose_name = _('funding')
+ verbose_name_plural = _('fundings')
+ ordering = ['-payed_at']
@classmethod
def payed(cls):
""" QuerySet for all completed payments. """
return cls.objects.exclude(payed_at=None)
- class Meta:
- verbose_name = _('funding')
- verbose_name_plural = _('fundings')
- ordering = ['-payed_at']
-
def __unicode__(self):
return unicode(self.offer)
def get_absolute_url(self):
return reverse('funding_funding', args=[self.pk])
+ def perk_names(self):
+ return ", ".join(perk.name for perk in self.perks.all())
+
+ def get_disable_notifications_url(self):
+ return "%s?%s" % (reverse("funding_disable_notifications"),
+ urlencode({
+ 'email': self.email,
+ 'key': self.notify_key,
+ }))
+
+ def save(self, *args, **kwargs):
+ if self.email and not self.notify_key:
+ self.notify_key = get_random_hash(self.email)
+ return super(Funding, self).save(*args, **kwargs)
+
+ @classmethod
+ def notify_funders(cls, subject, template_name, extra_context=None,
+ query_filter=None, payed_only=True):
+ funders = cls.objects.exclude(email="").filter(notifications=True)
+ if payed_only:
+ funders = funders.exclude(payed_at=None)
+ if query_filter is not None:
+ funders = funders.filter(query_filter)
+ emails = set()
+ for funder in funders:
+ if funder.email in emails:
+ continue
+ emails.add(funder.email)
+ funder.notify(subject, template_name, extra_context)
+
+ def notify(self, subject, template_name, extra_context=None):
+ context = {
+ 'funding': self,
+ 'site': Site.objects.get_current(),
+ }
+ if extra_context:
+ context.update(extra_context)
+ with override(self.language_code or app_settings.DEFAULT_LANGUAGE):
+ send_mail(subject,
+ render_to_string(template_name, context),
+ getattr(settings, 'CONTACT_EMAIL', 'wolnelektury@nowoczesnapolska.org.pl'),
+ [self.email],
+ fail_silently=False
+ )
+
+ def disable_notifications(self):
+ """Disables all notifications for this e-mail address."""
+ type(self).objects.filter(email=self.email).update(notifications=False)
+
+
# Register the Funding model with django-getpaid for payments.
getpaid.register_to_payment(Funding, unique=False, related_name='payment')
instance.order.payed_at = datetime.now()
instance.order.save()
if instance.order.email:
- send_thank_you_email(instance.order.name, instance.order.email, instance.order.language_code)
+ instance.order.notify(
+ _('Thank you for your support!'),
+ 'funding/email/thanks.txt'
+ )
getpaid.signals.payment_status_changed.connect(payment_status_changed_listener)
-
-def send_thank_you_email(name, address, language_code):
- with override(language_code or 'pl'):
- send_mail(_('Thank you for your support!'),
- render_to_string('funding/email.txt', dict(name = name)),
- getattr(settings, 'CONTACT_EMAIL', 'wolnelektury@nowoczesnapolska.org.pl'),
- [address],
- fail_silently=False
- )
-
--- /dev/null
+{% extends "admin/change_form.html" %}
+{% load i18n %}
+
+{% block extrahead %}
+{{ block.super }}
+<script type="text/javascript">
+(function($) {
+ $(document).ready(function($) {
+ $("#generated-switch").click(function() {
+ $('#generated').toggle()
+ });
+ });
+})(django.jQuery);
+</script>
+{% endblock %}
+
+
+
+{% block pretitle %}
+
+
+<a id="generated-switch">↓ {% trans "fundings" %} ↓</a>
+<div id="generated" style="display:none; padding:1em; border: 1px solid #aaa;">{% spaceless %}
+ {% for funding in original.funders %}
+ {% if funding.name %}
+ <dc:contributor.funding xml:lang="pl" xmlns:dc="http://purl.org/dc/elements/1.1/">{{ funding.name }}</dc:contributor.funding><br/>
+ {% endif %}
+ {% endfor %}
+{% endspaceless %}</div>
+{{ block.super }}
+{% endblock %}
--- /dev/null
+{% extends "base.html" %}
+{% load i18n %}
+{% load fnp_share %}
+
+{% block titleextra %}{% trans "Payment failed" %}{% endblock %}
+
+{% block body %}
+
+<h1>{% trans "Disable notifications" %}</h1>
+<div class="white-box normal-text">
+
+{% if view.object.notifications %}
+
+<p>{% blocktrans with e=view.object.email %}Are you sure you want to disable notifications for address {{e}}?{% endblocktrans %}</p>
+<form method="post" action="">
+ <button>{% trans "Disable notifications" %}</button>
+</form>
+
+{% else %}
+
+<p>{% blocktrans with e=view.object.email %}Notifications for address {{e}} have been successfully disabled.{% endblocktrans %}</p>
+
+{% endif %}
+
+{% url 'funding_current' as current %}
+<p>
+{% blocktrans with current=current %}Return to the <a href="{{current}}">current fundraiser</a>.{% endblocktrans %}
+</p>
+
+
+</div>
+
+
+{% endblock %}
+++ /dev/null
-{% load i18n %}
-
-{% trans 'Hi' %}{% if name %} {{name}}{% endif %},
-
-{% trans 'Thank you for your support - thanks to you we will set another book free.' %}{% if name %}
-
-{% trans 'The book will be supplemented with your name as a donor.' %}{% endif %}
-
-{% blocktrans %}We will contact you to keep you informed about your perks,
-status changes to this fundraiser and the incoming ones that we plan to launch.{% endblocktrans %}
-
-{% blocktrans %}Cheers,
-Wolne Lektury team{% endblocktrans %}
--- /dev/null
+{% autoescape off %}{% load i18n %}{% trans 'Hi' %}{% if funding.name %} {{ funding.name }}{% endif %},
+{% block body %}
+{% endblock %}
+{% blocktrans %}Cheers,
+Wolne Lektury team{% endblocktrans %}
+
+--
+{% blocktrans %}If you don't want to receive any more updates, please visit this page:{% endblocktrans %}
+http://{{site.domain}}{{ funding.get_disable_notifications_url }}
+{% endautoescape %}
--- /dev/null
+{% extends "funding/email/base.txt" %}
+{% load i18n %}
+
+
+{% block body %}{% if is_win %}
+{% blocktrans %}we succesfully collected the full amount needed
+for the book you contributed to:{% endblocktrans %}
+
+ {{ offer.author }} – {{ offer.title }}
+ http://{{ site.domain }}{{ offer.get_absolute_url }}
+
+{% blocktrans %}We will now digitize it, develop and publish it in the library,
+in various formats, free for everyone.{% endblocktrans %}
+{% if funding.name %}
+{% blocktrans %}Your name will be included on the list of contributors, irrespectively
+of the amount of your contribution.{% endblocktrans %}
+{% endif %}{# funding.name #}{% if funding.perks.exists %}
+{% blocktrans %}We will contact you again about details needed
+to deliver your perks.{% endblocktrans %}
+{% endif %}{# funding.perks.exists #}{% if remaining %}
+{% blocktrans with r=remaining %}All of the money remaining after this fundraiser ({{ r }} PLN)
+will be spent on liberating other books still waiting for publication.{% endblocktrans %}
+{% blocktrans %}You can see how we're spending these funds on this page:{% endblocktrans %}
+http://{{ site.domain }}{% url 'funding_wlfund' %}
+{% endif %}{# remaining #}{% else %}{# !is_win #}
+{% blocktrans %}unfortunately, we were unable to collect the full amount needed
+for the book you contributed to:{% endblocktrans %}
+
+ {{ offer.author }} – {{ offer.title }}
+ http://{{ site.domain }}{{ offer.get_absolute_url }}
+{% if remaining %}
+{% blocktrans with x=remaining %}All of the money we collected in this fundraiser ({{ x }} PLN)
+will be spent on liberating other books still waiting for publication.{% endblocktrans %}
+{% blocktrans %}You can see how we're spending these funds on this page:{% endblocktrans %}
+http://{{ site.domain }}{% url 'funding_wlfund' %}
+{% endif %}{# remaining #}{% endif %}{# is_win #}{% if current %}
+{% blocktrans %}If you'd like to help liberate another book, or invite your friends
+to do so, we're currently raising money for:{% endblocktrans %}
+
+ {{ current.author }} – {{ current.title }}
+ http://{{ site.domain }}{% url 'funding_current' %}
+{% endif %}{% endblock %}
--- /dev/null
+{% extends "funding/email/base.txt" %}
+{% load i18n %}
+
+{% block body %}
+{% blocktrans count days as d %}there's only {{ d }} day left until the end of the fundraiser for:
+{% plural %}There're only {{ d }} days left until the end of the fundraiser for:
+{% endblocktrans %}
+ {{ offer.author }} – {{ offer.title }}
+
+{% blocktrans with x=sum %}We managed to collect {{x}} PLN so far.{% endblocktrans %}
+{% if is_win %}
+{% blocktrans %}The fundraiser is a success already, but the more money
+we collect, the more other books we'll publish.{% endblocktrans %}
+{% else %}{% blocktrans with x=need %}We still need {{ x }} PLN more.{% endblocktrans %}
+{% endif %}
+{% trans "There's still time to let your friends know about the fundraiser!" %}
+http://{{ site.domain }}{% url 'funding_current' %}
+{% endblock %}
--- /dev/null
+{% extends "funding/email/base.txt" %}
+{% load i18n %}
+{% block body %}
+{% blocktrans %}we have just published the book you contributed to:{% endblocktrans %}
+
+ {{ author }} – {{ offer.book.title }}
+ http://{{ site.domain }}{{ offer.book.get_absolute_url }}
+
+{% blocktrans %}Thanks to you, it is now available for free,
+in various formats, to everyone.{% endblocktrans %}
+{% if current %}
+{% blocktrans %}If you'd like to help liberate another book, or invite your friends
+to do so, we're currently raising money for:{% endblocktrans %}
+
+ {{ current.author }} – {{ current.title }}
+ http://{{ site.domain }}{% url 'funding_current' %}
+{% endif %}{% endblock %}
--- /dev/null
+{% extends "funding/email/base.txt" %}
+{% load i18n %}
+
+
+{% block body %}
+{% trans 'Thank you for your support - thanks to you we will set another book free.' %}{% if funding.name %}
+
+{% trans 'The book will be supplemented with your name as a donor.' %}{% endif %}
+{% if funding.perks.exists %}
+{% blocktrans %}We will contact you about details needed for your perks.{% endblocktrans %}
+{% endif %}{# funding.perks.exists #}
+{% blocktrans %}We will keep you informed about status changes to this fundraiser
+and the upcoming ones that we plan to launch.{% endblocktrans %}
+{% endblock %}
<div class="normal-text">
<h3>{% trans "Support the publication" %}</h3>
<form action="" method="post">
- {% csrf_token %}
<table>
{{ form.as_table }}
<tr><td></td><td>
{% autopaginate object_list 10 %}
+{% if page_obj.number == 1 %}
+ <h2>{% trans "Current fundraiser:" %}</h2>
+{% endif %}
+
{% for offer in object_list %}
{% with is_win=offer.is_win is_current=offer.is_current %}
-
- {% if is_current %}
- <h2>{% trans "Current fundraiser:" %}</h2>
- {% elif forloop.is_first %}
+ {% if not is_current and forloop.first and page_obj.number == 1 %}
+ <p class="normal-text">{% trans "No fundraiser is currently running." %}</p>
<h2>{% trans "Previous fundraisers:" %}</h2>
{% endif %}
{% offer_status_more offer %}
</div>
- {% if is_current and not forloop.is_last %}
+ {% if is_current and not forloop.last %}
<h2>{% trans "Previous fundraisers:" %}</h2>
{% endif %}
{% if offer.is_current %}
{% if offer.is_win %}
<p>
- {% blocktrans with due=offer.due end=offer.end %}The fundraiser
- ends on {{ end }}. The book will be published by {{ due }}.{% endblocktrans %}
+ {% blocktrans with end=offer.end %}The fundraiser
+ ends on {{ end }}. The full amount has been successfully
+ raised, but you can still contribute and help liberate
+ more books.{% endblocktrans %}
</p>
{% else %}
<p>
{% blocktrans with bu=offer.book.get_absolute_url bt=offer.book %}The book
<a href="{{ bu }}">{{ bt }}</a> has been already published.{% endblocktrans %}
{% else %}
- {% blocktrans with due=offer.due %}The book
- will be published by {{ due }}.{% endblocktrans %}
- {% if offer.redakcja_link %}
+ {% if offer.redakcja_url %}
{% blocktrans with r=offer.redakcja_url %}You can follow
the work on the <a href="{{ r }}">Editorial Platform</a>.{% endblocktrans %}
{% endif %}
<h1>{% trans "Thank you!" %}</h1>
<div class="white-box normal-text">
-{% trans "Thank you for your support!" %}
+<p>{% trans "Thank you for your support!" %}</p>
+<p>{% blocktrans %}We will contact you if you qualify for perks.{% endblocktrans %}</p>
{% if offer.is_win %}
<p>{% trans "Full amount was successfully raised!" %}</p>
- <p>{% blocktrans with due=offer.due end=offer.end %}The fundraiser
- ends on {{ end }}. The book will be published by {{ due }}.{% endblocktrans %}</p>
+ <p>{% blocktrans with b=offer.title %}Your donation will be spent on digitizing, compiling and
+ publishing the book {{ b }} in multiple formats.{% endblocktrans %}</p>
+
{% else %}
- <p>
- {% blocktrans with b=offer.title %}Your donation will be spent on digitizing, compiling and
- publishing the book {{ b }} in multiple formats. We will contact you if you qualify for perks.{% endblocktrans %}
- </p>
+
+ <p>{% blocktrans with b=offer.title %}If the full amount needed is raised,
+ your donation will be spent on digitizing, compiling and
+ publishing the book {{ b }} in multiple formats.{% endblocktrans %}</p>
+
{% endif %}
+
<p>{% include "funding/snippets/any_remaining.html" %}
<a href="{% url 'infopage' 'wesprzyj' %}">{% trans "Learn more" %}</a>.</p>
<td>{{ entry.total }} zł</td>
</tr>
{% endif %}
+ {% empty %}
+ <tr><td colspan="4" style="text-align:center; color: #888;">
+ <em>{% trans "There are no previous fundraisers to show yet." %}</em>
+ </td></tr>
{% endfor %}
</table>
+
{% endblock %}
def funding(context, offer=None, link=False, closeable=False, show_title=True, show_title_calling = True, add_class=""):
if offer is None and context.get('funding_no_show_current') is None:
offer = Offer.current()
+ is_current = True
+ elif offer is not None:
+ is_current = offer.is_current()
+
if offer is None:
return {}
return {
'offer': offer,
'sum': offer_sum,
- 'is_current': offer.is_current(),
+ 'is_current': is_current,
'is_win': offer_sum >= offer.target,
'missing': offer.target - offer_sum,
'percentage': 100 * offer_sum / offer.target,
# 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, timedelta
from django.test import TestCase
from .models import Offer, Perk, Funding
-class FundTest(TestCase):
+class PerksTest(TestCase):
def setUp(self):
+ self.today = date.today()
self.offer1 = Offer.objects.create(
author='author1', title='title1', slug='slug1',
- target=100, start='2013-03-01', end='2013-03-31')
+ target=100, start=self.today, end=self.today)
def test_perks(self):
perk = Perk.objects.create(price=20, name='Perk 20')
perk1 = Perk.objects.create(offer=self.offer1, price=50, name='Perk 50')
offer2 = Offer.objects.create(
author='author2', title='title2', slug='slug2',
- target=100, start='2013-02-01', end='2013-02-20')
+ target=100, start=self.today-timedelta(1), end=self.today-timedelta(1))
perk2 = Perk.objects.create(offer=offer2, price=1, name='Perk 1')
self.assertEqual(
- set(self.offer1.fund('Tester', 'test@example.com', 10).perks.all()),
+ set(self.offer1.get_perks(10)),
set())
self.assertEqual(
- set(self.offer1.fund('Tester', 'test@example.com', 70).perks.all()),
+ set(self.offer1.get_perks(70)),
set([perk, perk1]))
+
+
+class FundingTest(TestCase):
+ def setUp(self):
+ self.today = date.today()
+ self.offer_past = Offer.objects.create(
+ author='an-author', title='past', slug='past',
+ target=100, start=self.today-timedelta(1), end=self.today-timedelta(1))
+ self.offer_current = Offer.objects.create(
+ author='an-author', title='current', slug='current',
+ target=100, start=self.today, end=self.today)
+ self.offer_future = Offer.objects.create(
+ author='an-author', title='future', slug='future',
+ target=100, start=self.today+timedelta(1), end=self.today+timedelta(1))
+
+ def test_current(self):
+ self.assertTrue(self.offer_current.is_current())
+ self.assertFalse(self.offer_past.is_current())
+ self.assertEqual(Offer.current(), self.offer_current)
+ self.assertEqual(
+ set(Offer.past()),
+ set([self.offer_past])
+ )
+ self.assertEqual(
+ set(Offer.public()),
+ set([self.offer_past, self.offer_current])
+ )
+
+ def test_interrupt(self):
+ # A new offer starts, ending the previously current one.
+ offer_interrupt = Offer.objects.create(
+ author='an-author', title='interrupt', slug='interrupt',
+ target=100, start=self.today-timedelta(1), end=self.today+timedelta(1))
+
+ self.assertTrue(offer_interrupt.is_current())
+ self.assertFalse(self.offer_current.is_current())
+ self.assertEqual(Offer.current(), offer_interrupt)
+ self.assertEqual(
+ set(Offer.past()),
+ set([self.offer_past, self.offer_current])
+ )
+ self.assertEqual(
+ set(Offer.public()),
+ set([self.offer_past, self.offer_current, offer_interrupt])
+ )
+
from .models import Offer
from .views import (WLFundView, OfferDetailView, OfferListView,
- ThanksView, NoThanksView, CurrentView)
+ ThanksView, NoThanksView, CurrentView, DisableNotifications)
urlpatterns = patterns('',
url(r'^$', CurrentView.as_view(), name='funding_current'),
+ url(r'^teraz/$', CurrentView.as_view()),
url(r'^teraz/(?P<slug>[^/]+)/$', CurrentView.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'^dziekujemy/$', ThanksView.as_view(), name='funding_thanks'),
url(r'^niepowodzenie/$', NoThanksView.as_view(), name='funding_nothanks'),
+
+ url(r'^wylacz_email/$', DisableNotifications.as_view(), name='funding_disable_notifications'),
url(r'^getpaid/', include('getpaid.urls')),
)
#
from datetime import date
from django.views.decorators.cache import never_cache
-from django.conf import settings
from django.core.urlresolvers import reverse
from django.http import Http404
from django.shortcuts import redirect, get_object_or_404
+from django.views.decorators.csrf import csrf_exempt
from django.views.generic import TemplateView, FormView, DetailView, ListView
import getpaid.backends.payu
from getpaid.models import Payment
+from . import app_settings
from .forms import FundingForm
from .models import Offer, Spent, Funding
template_name = "funding/offer_detail.html"
backend = 'getpaid.backends.payu'
+ @csrf_exempt
def dispatch(self, request, slug=None):
if getattr(self, 'object', None) is None:
if slug:
if self.request.method == 'POST':
return form_class(self.object, self.request.POST)
else:
- return form_class(self.object, initial={'amount': settings.FUNDING_DEFAULT})
+ return form_class(self.object, initial={'amount': app_settings.DEFAULT_AMOUNT})
def get_context_data(self, *args, **kwargs):
ctx = super(OfferDetailView, self).get_context_data(*args, **kwargs)
class CurrentView(OfferDetailView):
+ @csrf_exempt
def dispatch(self, request, slug=None):
self.object = Offer.current()
if self.object is None:
- raise Http404
+ return redirect(reverse('funding'))
elif slug != self.object.slug:
return redirect(reverse('funding_current', args=[self.object.slug]))
return super(CurrentView, self).dispatch(request, slug)
ctx['funding_no_show_current'] = True
return ctx
+
class NoThanksView(TemplateView):
template_name = "funding/no_thanks.html"
+
+
+class DisableNotifications(TemplateView):
+ template_name = "funding/disable_notifications.html"
+
+ @csrf_exempt
+ def dispatch(self, request):
+ self.object = get_object_or_404(Funding,
+ email=request.GET.get('email'), notify_key=request.GET.get('key'))
+ return super(DisableNotifications, self).dispatch(request)
+
+ def post(self, *args, **kwargs):
+ self.object.disable_notifications()
+ return redirect(self.request.get_full_path())
from django.utils import timezone
+make_time_naive = lambda d: timezone.localtime(d).replace(tzinfo=None)
+
WL_DC_READER_XPATH = '(.|*)/rdf:RDF/rdf:Description/%s/text()'
wl_dc_reader = metadata.MetadataReader(
fields={
identifier = self.slug_to_identifier(book.slug)
if isinstance(book, Book):
# setSpec = map(self.tag_to_setspec, book.tags.filter(category__in=self.TAG_CATEGORIES))
- header = common.Header(identifier, book.changed_at, [], False)
+ header = common.Header(identifier, make_time_naive(book.changed_at), [], False)
if not headers_only:
meta = common.Metadata(self.metadata(book))
about = None
elif isinstance(book, Deleted):
- header = common.Header(identifier, book.deleted_at, [], True)
+ header = common.Header(identifier, make_time_naive(book.deleted_at), [], True)
if not headers_only:
meta = common.Metadata({})
about = None
'%s/oaipmh' % WL_BASE, # generate
'2.0', # version
[m[1] for m in settings.MANAGERS], # adminEmails
- self.earliest_datestamp, # earliest datestamp of any change
+ make_time_naive(self.earliest_datestamp), # earliest datestamp of any change
'persistent', # deletedRecord
'YYYY-MM-DDThh:mm:ssZ', # granularity
['identity'], # compression
if not settings.NO_SEARCH_INDEX:
def update_index(sender, instance, **kwargs):
import search
- print "update pd index %s [update %s]" % (instance, 'created' in kwargs)
idx = search.Index()
- idx.open()
- try:
- idx.index_tags(instance, remove_only=not 'created' in kwargs)
- finally:
- idx.close()
+ idx.index_tags(instance, remove_only=not 'created' in kwargs)
post_delete.connect(update_index, Author)
post_delete.connect(update_index, BookStub)
def book_stub_detail(request, slug):
book = get_object_or_404(models.BookStub, slug=slug)
- pd_counter = datetime(book.pd, 1, 1)
+ if book.pd and not book.in_pd():
+ pd_counter = datetime(book.pd, 1, 1)
form = PublishingSuggestForm(
initial={"books": u"%s — %s, \n" % (book.author, book.title)})
def author_detail(request, slug):
author = get_object_or_404(models.Author, slug=slug)
- pd_counter = datetime(author.goes_to_pd(), 1, 1)
+ if not author.alive():
+ pd_counter = datetime(author.goes_to_pd(), 1, 1)
form = PublishingSuggestForm(initial={"books": author.name + ", \n"})
q_id_cat = self.index.Q(q_id & q_cat)
tag_qs.append(q_id_cat)
- self.delete_query(tag_qs)
+ self.delete_query(*tag_qs)
else: # all
q = self.index.Q(tag_id__any=True)
self.delete_query(q)
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Wolne Lektury</ShortName>
- <Description>WolneLektury.pl, szkolna biblioteka internetowa.</Description>
+ <Description>Biblioteka internetowa WolneLektury.pl</Description>
<InputEncoding>UTF-8</InputEncoding>
<Tags>lektury</Tags>
<Developer>Fundacja Nowoczesna Polska</Developer>
<body id="{% block bodyid %}base{% endblock %}">
{% block bodycontent %}
+ {% funding link=1 closeable=1 add_class="funding-top-header" %}
<div id="header-wrapper">
<header id="main">
<a href="/" id="logo">
-Subproject commit 3299c0d71150212730c3b7f9a1a54622c3213dc9
+Subproject commit a7d898e7b37b773ec111aa395f9591d61b7a1d46
# OAI-PMH
pyoai
-egenix-mx-base
+## egenix-mx-base # Doesn't play nice with mx in dist-packages.
sunburnt
django-getpaid>=1.4,<1.5
# set to 'new' or 'old' to skip time-consuming test
# for TeX morefloats library version
LIBRARIAN_PDF_MOREFLOATS = None
-
-FUNDING_DEFAULT = 20
-FUNDING_MIN_AMOUNT = 1