From: Radek Czajka
Date: Tue, 12 Nov 2013 11:57:43 +0000 (+0100)
Subject: Merge branch 'master' into rwd
X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/7f0caf88dd3aac2e4d5bb4ee064137e03ecd4f03?hp=9f4f697f0c6fe9a9d55bb45aaa93c804992f3339
Merge branch 'master' into rwd
Conflicts:
apps/wolnelektury_core/templates/superbase.html
---
diff --git a/apps/api/handlers.py b/apps/api/handlers.py
index 7f74c19e7..da5c0ed27 100644
--- a/apps/api/handlers.py
+++ b/apps/api/handlers.py
@@ -105,10 +105,6 @@ class BookMediaHandler(BaseHandler):
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. """
@@ -168,7 +164,12 @@ class AnonymousBooksHandler(AnonymousBaseHandler, BookDetails):
"""
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,
@@ -214,7 +215,7 @@ class AnonymousBooksHandler(AnonymousBaseHandler, BookDetails):
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):
@@ -240,8 +241,14 @@ def _tags_getter(category):
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):
diff --git a/apps/catalogue/locale/pl/LC_MESSAGES/django.mo b/apps/catalogue/locale/pl/LC_MESSAGES/django.mo
index 62671f116..6c1e2b692 100644
Binary files a/apps/catalogue/locale/pl/LC_MESSAGES/django.mo and b/apps/catalogue/locale/pl/LC_MESSAGES/django.mo differ
diff --git a/apps/catalogue/locale/pl/LC_MESSAGES/django.po b/apps/catalogue/locale/pl/LC_MESSAGES/django.po
index a2d12acae..1ecf8316d 100644
--- a/apps/catalogue/locale/pl/LC_MESSAGES/django.po
+++ b/apps/catalogue/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-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 \n"
"Language-Team: LANGUAGE \n"
"MIME-Version: 1.0\n"
@@ -98,7 +98,7 @@ msgstr "BÅÄ
d podczas importowania pliku: %r"
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"
@@ -272,7 +272,7 @@ msgstr ""
"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"
@@ -303,7 +303,7 @@ msgid ""
"Commons Attribution-ShareAlike 3.0\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 "
@@ -320,6 +320,10 @@ msgid "Edited and annotated by:"
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:"
@@ -331,53 +335,53 @@ msgstr "Spis wszystkich utworów"
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"
@@ -456,6 +460,7 @@ msgid "Mix this book"
msgstr "Miksuj treÅÄ utworu"
#: templates/catalogue/catalogue.html:6 templates/catalogue/catalogue.html:11
+#: templates/catalogue/menu.html:5
msgid "Catalogue"
msgstr "Katalog"
@@ -495,7 +500,7 @@ msgstr "Epoki"
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"
@@ -539,19 +544,23 @@ msgstr "ZwiÅ fragment"
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"
diff --git a/apps/catalogue/models/book.py b/apps/catalogue/models/book.py
index e80b8af73..d69cf2aca 100644
--- a/apps/catalogue/models/book.py
+++ b/apps/catalogue/models/book.py
@@ -75,7 +75,7 @@ class Book(models.Model):
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()
@@ -511,10 +511,11 @@ class Book(models.Model):
"""
# 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)
diff --git a/apps/catalogue/models/listeners.py b/apps/catalogue/models/listeners.py
index cb106166e..373a2fcc8 100644
--- a/apps/catalogue/models/listeners.py
+++ b/apps/catalogue/models/listeners.py
@@ -40,6 +40,14 @@ def _pre_delete_handler(sender, instance, **kwargs):
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:
@@ -48,6 +56,7 @@ def _post_save_handler(sender, instance, **kwargs):
'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)
@@ -63,9 +72,5 @@ if not settings.NO_SEARCH_INDEX:
""" 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()
diff --git a/apps/catalogue/templates/catalogue/book_info.html b/apps/catalogue/templates/catalogue/book_info.html
index c5006f1ed..a90ccdc87 100755
--- a/apps/catalogue/templates/catalogue/book_info.html
+++ b/apps/catalogue/templates/catalogue/book_info.html
@@ -29,6 +29,12 @@
{% all_editors book.extra_info %}.
{% endif %}
+{% if book.extra_info.funders %}
+ {% trans "Publication funded by:" %}
+ {% for funder in book.extra_info.funders %}{{ funder }}{% if not forloop.last %}, {% else %}.{% endif %}{% endfor %}
+
+{% endif %}
+
{% if book.extra_info.cover_by %}
{% trans "Cover image by:" %}
diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py
index d69e5428c..e9b1465dd 100644
--- a/apps/catalogue/views.py
+++ b/apps/catalogue/views.py
@@ -186,7 +186,7 @@ def tagged_object_list(request, tags=''):
# 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
diff --git a/apps/dictionary/templates/dictionary/note_list.html b/apps/dictionary/templates/dictionary/note_list.html
index 097457eda..5bf9e3f4c 100755
--- a/apps/dictionary/templates/dictionary/note_list.html
+++ b/apps/dictionary/templates/dictionary/note_list.html
@@ -35,7 +35,7 @@
{% blocktrans count object_list.count as c %}{{c}} footnote found{% plural %}{{c}} footnotes found{% endblocktrans %}
-{% if object_list %}
+{% if object_list.exists %}
{% autopaginate object_list 100 %}
{% paginate %}
diff --git a/apps/funding/__init__.py b/apps/funding/__init__.py
index e69de29bb..9e81e9ec3 100644
--- a/apps/funding/__init__.py
+++ b/apps/funding/__init__.py
@@ -0,0 +1,17 @@
+# -*- 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')
diff --git a/apps/funding/admin.py b/apps/funding/admin.py
index 66cff10f7..d70aef66a 100644
--- a/apps/funding/admin.py
+++ b/apps/funding/admin.py
@@ -1,23 +1,62 @@
+# -*- 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):
diff --git a/apps/funding/forms.py b/apps/funding/forms.py
index dc0e6236d..64cceb6ad 100644
--- a/apps/funding/forms.py
+++ b/apps/funding/forms.py
@@ -1,9 +1,13 @@
-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):
@@ -14,8 +18,9 @@ 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.
"
- "Won't be publicised."), required=False)
+ help_text=_("We'll use it to contact you about the details needed for your perks,
"
+ "and to send you updates about your payment and the fundraiser status (which you can always turn off).
"
+ "Your e-mail won't be publicised."), required=False)
def __init__(self, offer, *args, **kwargs):
self.offer = offer
@@ -23,10 +28,10 @@ class FundingForm(forms.Form):
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})
diff --git a/apps/funding/locale/pl/LC_MESSAGES/django.mo b/apps/funding/locale/pl/LC_MESSAGES/django.mo
index a2ca35f45..9f86a860d 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 716871916..9b4e03449 100644
--- a/apps/funding/locale/pl/LC_MESSAGES/django.po
+++ b/apps/funding/locale/pl/LC_MESSAGES/django.po
@@ -7,10 +7,11 @@ msgid ""
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 \n"
"Language-Team: LANGUAGE \n"
+"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -18,199 +19,220 @@ msgstr ""
"|| 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.
Won't be publicised."
+"We'll use it to contact you about the details needed for your perks"
+"strong>,
and to send you updates about your payment and the fundraiser "
+"status (which you can always turn off).
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.
Nie bÄdzie publikowany."
+"Użyjemy go do kontaktu w sprawie danych potrzebnych do realizacji "
+"prezentów
i do informowania CiÄ o zmianach statusu pÅatnoÅci i "
+"zbiórki (z czego zawsze możesz zrezygnowaÄ).
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 current fundraiser."
+msgstr "WrÃ³Ä do aktualnej zbiórki."
#: templates/funding/no_thanks.html:12
msgid "You're support has not been processed successfully."
@@ -225,13 +247,13 @@ msgstr ""
"WrÃ³Ä do aktualnej zbiórki 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"
@@ -240,27 +262,27 @@ 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"
@@ -268,11 +290,15 @@ 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:"
@@ -280,38 +306,44 @@ 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"
@@ -357,6 +389,158 @@ msgstr "PieniÄ
dze przeznaczone na opublikowanie ksiÄ
żki"
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 ""
@@ -390,7 +574,18 @@ msgstr "potrzebujemy"
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"
@@ -399,7 +594,7 @@ msgstr ""
"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"
@@ -408,7 +603,7 @@ msgstr ""
"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."
@@ -425,14 +620,7 @@ msgstr ""
"KsiÄ
żka\n"
" %(bt)s 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"
@@ -442,3 +630,21 @@ msgstr "Możesz ÅledziÄ prace na Platformie Redakcyjnej.
#: 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."
diff --git a/apps/funding/management/__init__.py b/apps/funding/management/__init__.py
new file mode 100755
index 000000000..e69de29bb
diff --git a/apps/funding/management/commands/__init__.py b/apps/funding/management/commands/__init__.py
new file mode 100755
index 000000000..e69de29bb
diff --git a/apps/funding/management/commands/funding_notify.py b/apps/funding/management/commands/funding_notify.py
new file mode 100755
index 000000000..a583b2785
--- /dev/null
+++ b/apps/funding/management/commands/funding_notify.py
@@ -0,0 +1,35 @@
+# -*- 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()
diff --git a/apps/funding/migrations/0015_auto__add_field_funding_notifications__add_field_funding_notify_key.py b/apps/funding/migrations/0015_auto__add_field_funding_notifications__add_field_funding_notify_key.py
new file mode 100644
index 000000000..dd9a41eb2
--- /dev/null
+++ b/apps/funding/migrations/0015_auto__add_field_funding_notifications__add_field_funding_notify_key.py
@@ -0,0 +1,117 @@
+# -*- 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
diff --git a/apps/funding/migrations/0016_auto__del_field_offer_due.py b/apps/funding/migrations/0016_auto__del_field_offer_due.py
new file mode 100644
index 000000000..13351005f
--- /dev/null
+++ b/apps/funding/migrations/0016_auto__del_field_offer_due.py
@@ -0,0 +1,100 @@
+# -*- 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
diff --git a/apps/funding/migrations/0017_auto__add_field_offer_notified_near__add_field_offer_notified_end.py b/apps/funding/migrations/0017_auto__add_field_offer_notified_near__add_field_offer_notified_end.py
new file mode 100644
index 000000000..4f12e4d9f
--- /dev/null
+++ b/apps/funding/migrations/0017_auto__add_field_offer_notified_near__add_field_offer_notified_end.py
@@ -0,0 +1,112 @@
+# -*- 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
diff --git a/apps/funding/models.py b/apps/funding/models.py
index 8c3312ee8..de52ac9d8 100644
--- a/apps/funding/models.py
+++ b/apps/funding/models.py
@@ -3,15 +3,19 @@
# 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):
@@ -23,14 +27,15 @@ 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'' % self.cover.url
cover_img_tag.short_description = _('Cover preview')
@@ -47,8 +52,17 @@ class Offer(models.Model):
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
@@ -63,9 +77,16 @@ class Offer(models.Model):
@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:
@@ -73,9 +94,12 @@ class Offer(models.Model):
@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):
@@ -100,10 +124,61 @@ class Offer(models.Model):
""" 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.
@@ -134,30 +209,80 @@ class Funding(models.Model):
"""
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')
@@ -195,15 +320,8 @@ def payment_status_changed_listener(sender, instance, old_status, new_status, **
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
- )
-
diff --git a/apps/funding/templates/admin/funding/offer/change_form.html b/apps/funding/templates/admin/funding/offer/change_form.html
new file mode 100755
index 000000000..292d0dfeb
--- /dev/null
+++ b/apps/funding/templates/admin/funding/offer/change_form.html
@@ -0,0 +1,31 @@
+{% extends "admin/change_form.html" %}
+{% load i18n %}
+
+{% block extrahead %}
+{{ block.super }}
+
+{% endblock %}
+
+
+
+{% block pretitle %}
+
+
+â {% trans "fundings" %} â
+{% 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>
+ {% endif %}
+ {% endfor %}
+{% endspaceless %}
+{{ block.super }}
+{% endblock %}
diff --git a/apps/funding/templates/funding/disable_notifications.html b/apps/funding/templates/funding/disable_notifications.html
new file mode 100755
index 000000000..9123310d9
--- /dev/null
+++ b/apps/funding/templates/funding/disable_notifications.html
@@ -0,0 +1,34 @@
+{% extends "base.html" %}
+{% load i18n %}
+{% load fnp_share %}
+
+{% block titleextra %}{% trans "Payment failed" %}{% endblock %}
+
+{% block body %}
+
+{% trans "Disable notifications" %}
+
+
+{% if view.object.notifications %}
+
+
{% blocktrans with e=view.object.email %}Are you sure you want to disable notifications for address {{e}}?{% endblocktrans %}
+
+
+{% else %}
+
+
{% blocktrans with e=view.object.email %}Notifications for address {{e}} have been successfully disabled.{% endblocktrans %}
+
+{% endif %}
+
+{% url 'funding_current' as current %}
+
+{% blocktrans with current=current %}Return to the current fundraiser.{% endblocktrans %}
+
+
+
+
+
+
+{% endblock %}
diff --git a/apps/funding/templates/funding/email.txt b/apps/funding/templates/funding/email.txt
deleted file mode 100644
index e5487671d..000000000
--- a/apps/funding/templates/funding/email.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-{% 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 %}
diff --git a/apps/funding/templates/funding/email/base.txt b/apps/funding/templates/funding/email/base.txt
new file mode 100755
index 000000000..1129549ce
--- /dev/null
+++ b/apps/funding/templates/funding/email/base.txt
@@ -0,0 +1,10 @@
+{% 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 %}
diff --git a/apps/funding/templates/funding/email/end.txt b/apps/funding/templates/funding/email/end.txt
new file mode 100755
index 000000000..023d34427
--- /dev/null
+++ b/apps/funding/templates/funding/email/end.txt
@@ -0,0 +1,42 @@
+{% 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 %}
diff --git a/apps/funding/templates/funding/email/near.txt b/apps/funding/templates/funding/email/near.txt
new file mode 100755
index 000000000..47537c129
--- /dev/null
+++ b/apps/funding/templates/funding/email/near.txt
@@ -0,0 +1,18 @@
+{% 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 %}
diff --git a/apps/funding/templates/funding/email/published.txt b/apps/funding/templates/funding/email/published.txt
new file mode 100755
index 000000000..672efa2ae
--- /dev/null
+++ b/apps/funding/templates/funding/email/published.txt
@@ -0,0 +1,17 @@
+{% 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 %}
diff --git a/apps/funding/templates/funding/email/thanks.txt b/apps/funding/templates/funding/email/thanks.txt
new file mode 100644
index 000000000..2ded0bd9d
--- /dev/null
+++ b/apps/funding/templates/funding/email/thanks.txt
@@ -0,0 +1,14 @@
+{% 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 %}
diff --git a/apps/funding/templates/funding/no_thanks.html b/apps/funding/templates/funding/no_thanks.html
old mode 100755
new mode 100644
diff --git a/apps/funding/templates/funding/offer_detail.html b/apps/funding/templates/funding/offer_detail.html
old mode 100755
new mode 100644
index c5631b086..aef4d28af
--- a/apps/funding/templates/funding/offer_detail.html
+++ b/apps/funding/templates/funding/offer_detail.html
@@ -43,7 +43,6 @@
{% trans "Support the publication" %}