*~
*.orig
*.log
+.sass-cache
# Compress output
/static
--- /dev/null
+from django.contrib import admin
+from .models import Offer, Perk, Funding, Spent
+
+admin.site.register(Spent)
+admin.site.register(Offer)
+admin.site.register(Perk)
+admin.site.register(Funding)
--- /dev/null
+from django import forms
+from django.utils.translation import ugettext_lazy as _, ugettext as __
+from .models import Offer
+from .widgets import PerksAmountWidget
+
+
+class DummyForm(forms.Form):
+ required_css_class = 'required'
+
+ name = forms.CharField(label=_("Name"))
+ anonymous = forms.BooleanField(label=_("Anonymously"),
+ required=False,
+ help_text=_("Check if you don't want your name to be visible publicly."))
+ email = forms.EmailField(label=_("E-mail"),
+ help_text=_("Won't be publicised."))
+ amount = forms.DecimalField(label=_("Amount"), decimal_places=2,
+ widget=PerksAmountWidget())
+
+ def __init__(self, offer, *args, **kwargs):
+ self.offer = offer
+ super(DummyForm, self).__init__(*args, **kwargs)
+ self.fields['amount'].widget.form_instance = self
+
+ def clean_amount(self):
+ if self.cleaned_data['amount'] <= 0:
+ raise forms.ValidationError(__("Enter positive amount."))
+ return self.cleaned_data['amount']
+
+ def clean(self):
+ if not self.offer.is_current():
+ raise forms.ValidationError(__("This offer is out of date."))
+ return self.cleaned_data
+
+ def save(self):
+ return self.offer.fund(
+ name=self.cleaned_data['name'],
+ email=self.cleaned_data['email'],
+ amount=self.cleaned_data['amount'],
+ anonymous=self.cleaned_data['anonymous'],
+ )
+
--- /dev/null
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-03-27 17:36+0100\n"
+"PO-Revision-Date: 2013-03-27 17:36+0100\n"
+"Last-Translator: Radek Czajka <radek.czajka@gmail.com>\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"
+"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
+
+#: forms.py:10
+msgid "Name"
+msgstr "Imię i nazwisko"
+
+#: forms.py:11
+msgid "Anonymously"
+msgstr "Anonimowo"
+
+#: forms.py:13
+msgid "Check if you don't want your name to be visible publicly."
+msgstr "Zaznacz, jeśli nie chcesz by Twoje nazwisko było widoczne publicznie."
+
+#: forms.py:14
+msgid "E-mail"
+msgstr "E-mail"
+
+#: forms.py:15
+msgid "Won't be publicised."
+msgstr "Nie zostanie opublikowany."
+
+#: forms.py:16
+msgid "Amount"
+msgstr "Kwota"
+
+#: models.py:13
+msgid "author"
+msgstr "autor"
+
+#: models.py:14
+msgid "title"
+msgstr "tytuł"
+
+#: models.py:15
+msgid "slug"
+msgstr "slug"
+
+#: models.py:17
+msgid "Published book."
+msgstr "Opublikowana książka."
+
+#: models.py:18
+msgid "redakcja URL"
+msgstr "URL na Redakcji"
+
+#: models.py:19
+msgid "target"
+msgstr "kwota docelowa"
+
+#: models.py:20
+msgid "start"
+msgstr "początek"
+
+#: models.py:21
+msgid "end"
+msgstr "koniec"
+
+#: models.py:22
+msgid "due"
+msgstr "data publikacji"
+
+#: models.py:23
+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:26
+#: models.py:82
+#: models.py:97
+msgid "offer"
+msgstr "zbiórka"
+
+#: models.py:27
+msgid "offers"
+msgstr "zbiórki"
+
+#: models.py:83
+msgid "price"
+msgstr "cena"
+
+#: models.py:84
+#: models.py:98
+msgid "name"
+msgstr "nazwa"
+
+#: models.py:85
+msgid "description"
+msgstr "opis"
+
+#: models.py:88
+msgid "perk"
+msgstr "prezent"
+
+#: models.py:89
+#: models.py:102
+msgid "perks"
+msgstr "prezenty"
+
+#: models.py:99
+msgid "email"
+msgstr "e-mail"
+
+#: models.py:100
+#: models.py:115
+msgid "amount"
+msgstr "kwota"
+
+#: models.py:101
+msgid "payed at"
+msgstr "data wpłaty"
+
+#: models.py:103
+msgid "anonymous"
+msgstr "anonimowo"
+
+#: models.py:106
+msgid "funding"
+msgstr "wpłata"
+
+#: models.py:107
+msgid "fundings"
+msgstr "wpłaty"
+
+#: models.py:116
+msgid "when"
+msgstr "kiedy"
+
+#: models.py:120
+msgid "money spent on a book"
+msgstr "pieniądze wydane na książkę"
+
+#: models.py:121
+msgid "money spent on books"
+msgstr "pieniądze wydane na książki"
+
+#: templates/funding/offer_detail.html:22
+msgid "Support"
+msgstr "Wesprzyj"
+
+#: templates/funding/offer_detail.html:39
+msgid "Supporters"
+msgstr "Wpłaty"
+
+#: templates/funding/offer_detail.html:49
+msgid "Anonymous"
+msgstr "Anonim"
+
+#: templates/funding/offer_list.html:6
+#: templates/funding/offer_list.html:9
+msgid "Support Wolne Lektury"
+msgstr "Wspieraj Wolne Lektury"
+
+#: templates/funding/offer_list.html:16
+msgid "funding closed"
+msgstr "zbiórka zakończona"
+
+#: templates/funding/thanks.html:5
+#: templates/funding/thanks.html.py:9
+msgid "Thank you!"
+msgstr "Dziękujemy!"
+
+#: templates/funding/thanks.html:12
+msgid "Thank you for your support!"
+msgstr "Dziękujemy za Twoje wsparcie!"
+
+#: templates/funding/thanks.html:14
+msgid "Go back to the current fundraiser."
+msgstr "Wróć do aktualnej zbiórki."
+
+#: templates/funding/wlfund.html:4
+#: templates/funding/wlfund.html.py:8
+msgid "Wolne Lektury Fund"
+msgstr "Fundusz Wolnych Lektur"
+
+#: templates/funding/wlfund.html:14
+msgid "Balance"
+msgstr "Bilans"
+
+#: templates/funding/wlfund.html:26
+msgid "Book"
+msgstr "Książka"
+
+#: templates/funding/wlfund.html:34
+msgid "Excessive money from fundraiser"
+msgstr "Pieniądze pozostałe ze zbiórki"
+
+#: templates/funding/tags/funding.html:10
+msgid "Support a book:"
+msgstr "Wesprzyj książkę:"
+
+#: templates/funding/tags/funding.html:14
+msgid "collected"
+msgstr "zebrane"
+
+#: templates/funding/tags/funding.html:16
+msgid "until fundraiser end"
+msgstr "do końca zbiórki"
+
+#: templates/funding/tags/offer_detail_head.html:5
+#, python-format
+msgid ""
+"If the target is met\n"
+" by %(end)s, this book will be published by %(due)s."
+msgstr "Jeśli do %(end)s uda się zebrać pełną kwotę, książka zostanie opublikowana do %(due)s."
+
+#: templates/funding/tags/offer_detail_head.html:10
+#, python-format
+msgid ""
+"Any excessive money will be transfered to the\n"
+" <a href=\"%(url)s\">Wolne Lektury Fund</a>."
+msgstr ""
+"Wszelkie pozostałe środki zostaną przekazane na\n"
+" <a href=\"%(url)s\">Fundusz Wolnych Lektur</a>."
+
+#: templates/funding/tags/offer_detail_head.html:15
+msgid "See the published book:"
+msgstr "Zobacz opublikowaną książkę:"
+
+#: templates/funding/tags/offer_detail_head.html:18
+msgid "Funding target has been met!"
+msgstr "Udało się zebrać pełną kwotę!"
+
+#: templates/funding/tags/offer_detail_head.html:19
+msgid "The book will be published by:"
+msgstr "Książka zostanie opublikowana do"
+
+#: templates/funding/tags/offer_detail_head.html:22
+#, python-format
+msgid "You can follow the work on the <a href=\"%(url)s\">Editorial Platform</a>."
+msgstr "Możesz śledzić prace na <a href=\"%(url)s\">Platformie Redakcyjnej</a>."
+
+#: templates/funding/tags/offer_detail_head.html:28
+msgid "Funding target has not been met."
+msgstr "Nie udało się zebrać pełnej kwoty."
+
+#: templates/funding/tags/offer_detail_head.html:31
+#, python-format
+msgid ""
+"Collected funds have been transfered to the\n"
+" <a href=\"%(url)s\">Wolne Lektury Fund</a>."
+msgstr ""
+"Zebrane środki zostały przekazane na\n"
+" <a href=\"%(url)s\">Fundusz Wolnych Lektur</a>."
+
+#: templates/funding/widgets/amount.html:12
+msgid "Other amount"
+msgstr "Inna kwota"
+
--- /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 model 'Offer'
+ db.create_table('funding_offer', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('author', self.gf('django.db.models.fields.CharField')(max_length=255)),
+ ('title', self.gf('django.db.models.fields.CharField')(max_length=255)),
+ ('slug', self.gf('django.db.models.fields.SlugField')(max_length=50)),
+ ('book_url', self.gf('django.db.models.fields.URLField')(max_length=200, blank=True)),
+ ('redakcja_url', self.gf('django.db.models.fields.URLField')(max_length=200, blank=True)),
+ ('target', self.gf('django.db.models.fields.DecimalField')(max_digits=10, decimal_places=2)),
+ ('start', self.gf('django.db.models.fields.DateField')()),
+ ('end', self.gf('django.db.models.fields.DateField')()),
+ ))
+ db.send_create_signal('funding', ['Offer'])
+
+ # Adding model 'Perk'
+ db.create_table('funding_perk', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('offer', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['funding.Offer'], null=True)),
+ ('price', self.gf('django.db.models.fields.DecimalField')(max_digits=10, decimal_places=2)),
+ ('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
+ ('description', self.gf('django.db.models.fields.TextField')(blank=True)),
+ ))
+ db.send_create_signal('funding', ['Perk'])
+
+ # Adding model 'Funding'
+ db.create_table('funding_funding', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('offer', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['funding.Offer'])),
+ ('name', self.gf('django.db.models.fields.CharField')(max_length=127)),
+ ('email', self.gf('django.db.models.fields.EmailField')(max_length=75)),
+ ('amount', self.gf('django.db.models.fields.DecimalField')(max_digits=10, decimal_places=2)),
+ ('payed_at', self.gf('django.db.models.fields.DateTimeField')()),
+ ))
+ db.send_create_signal('funding', ['Funding'])
+
+ # Adding M2M table for field perks on 'Funding'
+ db.create_table('funding_funding_perks', (
+ ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
+ ('funding', models.ForeignKey(orm['funding.funding'], null=False)),
+ ('perk', models.ForeignKey(orm['funding.perk'], null=False))
+ ))
+ db.create_unique('funding_funding_perks', ['funding_id', 'perk_id'])
+
+
+ def backwards(self, orm):
+ # Deleting model 'Offer'
+ db.delete_table('funding_offer')
+
+ # Deleting model 'Perk'
+ db.delete_table('funding_perk')
+
+ # Deleting model 'Funding'
+ db.delete_table('funding_funding')
+
+ # Removing M2M table for field perks on 'Funding'
+ db.delete_table('funding_funding_perks')
+
+
+ models = {
+ 'funding.funding': {
+ 'Meta': {'ordering': "['-payed_at']", 'object_name': 'Funding'},
+ 'amount': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '127'}),
+ 'offer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['funding.Offer']"}),
+ 'payed_at': ('django.db.models.fields.DateTimeField', [], {}),
+ 'perks': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['funding.Perk']", 'symmetrical': 'False'})
+ },
+ 'funding.offer': {
+ 'Meta': {'ordering': "['-end']", 'object_name': 'Offer'},
+ 'author': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'book_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
+ 'end': ('django.db.models.fields.DateField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'redakcja_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'}),
+ 'start': ('django.db.models.fields.DateField', [], {}),
+ 'target': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ },
+ 'funding.perk': {
+ 'Meta': {'ordering': "['-price']", 'object_name': 'Perk'},
+ 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'offer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['funding.Offer']", 'null': 'True'}),
+ 'price': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'})
+ }
+ }
+
+ 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 model 'Spent'
+ db.create_table('funding_spent', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('amount', self.gf('django.db.models.fields.DecimalField')(max_digits=10, decimal_places=2)),
+ ('timestamp', self.gf('django.db.models.fields.DateField')()),
+ ('book', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['catalogue.Book'])),
+ ))
+ db.send_create_signal('funding', ['Spent'])
+
+ # Deleting field 'Offer.book_url'
+ db.delete_column('funding_offer', 'book_url')
+
+ # Adding field 'Offer.book'
+ db.add_column('funding_offer', 'book',
+ self.gf('django.db.models.fields.related.ForeignKey')(to=orm['catalogue.Book'], null=True, blank=True),
+ keep_default=False)
+
+
+ def backwards(self, orm):
+ # Deleting model 'Spent'
+ db.delete_table('funding_spent')
+
+ # Adding field 'Offer.book_url'
+ db.add_column('funding_offer', 'book_url',
+ self.gf('django.db.models.fields.URLField')(default='', max_length=200, blank=True),
+ keep_default=False)
+
+ # Deleting field 'Offer.book'
+ db.delete_column('funding_offer', 'book_id')
+
+
+ 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'}),
+ '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'})
+ },
+ 'funding.funding': {
+ 'Meta': {'ordering': "['-payed_at']", 'object_name': 'Funding'},
+ 'amount': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '127'}),
+ 'offer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['funding.Offer']"}),
+ 'payed_at': ('django.db.models.fields.DateTimeField', [], {}),
+ 'perks': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['funding.Perk']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ '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'}),
+ 'end': ('django.db.models.fields.DateField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'redakcja_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'}),
+ 'start': ('django.db.models.fields.DateField', [], {}),
+ 'target': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ },
+ 'funding.perk': {
+ 'Meta': {'ordering': "['-price']", 'object_name': 'Perk'},
+ 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'offer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['funding.Offer']", 'null': 'True', 'blank': 'True'}),
+ 'price': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'})
+ },
+ 'funding.spent': {
+ 'Meta': {'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']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'timestamp': ('django.db.models.fields.DateField', [], {})
+ }
+ }
+
+ complete_apps = ['funding']
\ No newline at end of file
--- /dev/null
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Adding field 'Offer.due'
+ db.add_column('funding_offer', 'due',
+ self.gf('django.db.models.fields.DateField')(default=datetime.datetime(2013, 3, 27, 0, 0)),
+ keep_default=False)
+
+
+ def backwards(self, orm):
+ # Deleting field 'Offer.due'
+ db.delete_column('funding_offer', 'due')
+
+
+ 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'}),
+ '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'})
+ },
+ 'funding.funding': {
+ 'Meta': {'ordering': "['-payed_at']", 'object_name': 'Funding'},
+ 'amount': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '127'}),
+ 'offer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['funding.Offer']"}),
+ 'payed_at': ('django.db.models.fields.DateTimeField', [], {}),
+ 'perks': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['funding.Perk']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ 'funding.offer': {
+ 'Meta': {'ordering': "['-end']", 'object_name': 'Offer'},
+ 'author': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'book': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Book']", 'null': 'True', 'blank': 'True'}),
+ 'due': ('django.db.models.fields.DateField', [], {}),
+ 'end': ('django.db.models.fields.DateField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'redakcja_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'}),
+ 'start': ('django.db.models.fields.DateField', [], {}),
+ 'target': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ },
+ 'funding.perk': {
+ 'Meta': {'ordering': "['-price']", 'object_name': 'Perk'},
+ 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'offer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['funding.Offer']", 'null': 'True', 'blank': 'True'}),
+ 'price': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'})
+ },
+ 'funding.spent': {
+ 'Meta': {'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']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'timestamp': ('django.db.models.fields.DateField', [], {})
+ }
+ }
+
+ complete_apps = ['funding']
\ No newline at end of file
--- /dev/null
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Adding field 'Funding.anonymous'
+ db.add_column('funding_funding', 'anonymous',
+ self.gf('django.db.models.fields.BooleanField')(default=False),
+ keep_default=False)
+
+
+ def backwards(self, orm):
+ # Deleting field 'Funding.anonymous'
+ db.delete_column('funding_funding', 'anonymous')
+
+
+ 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'}),
+ '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'})
+ },
+ 'funding.funding': {
+ 'Meta': {'ordering': "['-payed_at']", 'object_name': 'Funding'},
+ 'amount': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
+ 'anonymous': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '127'}),
+ 'offer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['funding.Offer']"}),
+ 'payed_at': ('django.db.models.fields.DateTimeField', [], {}),
+ 'perks': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['funding.Perk']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ 'funding.offer': {
+ 'Meta': {'ordering': "['-end']", 'object_name': 'Offer'},
+ 'author': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'book': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Book']", 'null': 'True', 'blank': 'True'}),
+ 'due': ('django.db.models.fields.DateField', [], {}),
+ 'end': ('django.db.models.fields.DateField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'redakcja_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50'}),
+ 'start': ('django.db.models.fields.DateField', [], {}),
+ 'target': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ },
+ 'funding.perk': {
+ 'Meta': {'ordering': "['-price']", 'object_name': 'Perk'},
+ 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'offer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['funding.Offer']", 'null': 'True', 'blank': 'True'}),
+ 'price': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'})
+ },
+ 'funding.spent': {
+ 'Meta': {'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']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'timestamp': ('django.db.models.fields.DateField', [], {})
+ }
+ }
+
+ complete_apps = ['funding']
\ No newline at end of file
--- /dev/null
+# -*- coding: utf-8 -*-
+# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
+from django.core.urlresolvers import reverse
+from django.db import models
+from django.utils.translation import ugettext_lazy as _, ugettext as __
+from datetime import date, datetime
+from catalogue.models import Book
+
+
+class Offer(models.Model):
+ author = models.CharField(_('author'), max_length=255)
+ title = models.CharField(_('title'), max_length=255)
+ slug = models.SlugField(_('slug'))
+ book = models.ForeignKey(Book, null=True, blank=True,
+ help_text=_('Published book.'))
+ redakcja_url = models.URLField(_('redakcja URL'), blank=True)
+ target = models.DecimalField(_('target'), decimal_places=2, max_digits=10)
+ start = models.DateField(_('start'))
+ end = models.DateField(_('end'))
+ due = models.DateField(_('due'),
+ help_text=_('When will it be published if the money is raised.'))
+
+ class Meta:
+ verbose_name = _('offer')
+ verbose_name_plural = _('offers')
+ ordering = ['-end']
+
+ def __unicode__(self):
+ return u"%s – %s" % (self.author, self.title)
+
+ def get_absolute_url(self):
+ return reverse('funding_offer', args=[self.slug])
+
+ def is_current(self):
+ return self.start <= date.today() <= self.end
+
+ @classmethod
+ def current(cls):
+ today = date.today()
+ objects = cls.objects.filter(start__lte=today, end__gte=today)
+ try:
+ return objects[0]
+ except IndexError:
+ return None
+
+ @classmethod
+ def public(cls):
+ today = date.today()
+ return cls.objects.filter(start__lte=today)
+
+ def get_perks(self, amount=None):
+ perks = Perk.objects.filter(
+ models.Q(offer=self) | models.Q(offer=None)
+ )
+ if amount is not None:
+ perks = perks.filter(price__lte=amount)
+ return perks
+
+ def fund(self, name, email, amount, anonymous=False):
+ funding = self.funding_set.create(
+ name=name, email=email, amount=amount,
+ anonymous=anonymous,
+ payed_at=datetime.now())
+ funding.perks = self.get_perks(amount)
+ return funding
+
+ def sum(self):
+ return self.funding_set.aggregate(s=models.Sum('amount'))['s'] or 0
+
+ def state(self):
+ if self.sum() >= self.target:
+ return 'win'
+ elif self.start <= date.today() <= self.end:
+ return 'running'
+ else:
+ return 'lose'
+
+
+class Perk(models.Model):
+ offer = models.ForeignKey(Offer, verbose_name=_('offer'), null=True, blank=True)
+ price = models.DecimalField(_('price'), decimal_places=2, max_digits=10)
+ name = models.CharField(_('name'), max_length=255)
+ description = models.TextField(_('description'), blank=True)
+
+ class Meta:
+ verbose_name = _('perk')
+ verbose_name_plural = _('perks')
+ ordering = ['-price']
+
+ def __unicode__(self):
+ return "%s (%s%s)" % (self.name, self.price, u" for %s" % self.offer if self.offer else "")
+
+
+class Funding(models.Model):
+ offer = models.ForeignKey(Offer, verbose_name=_('offer'))
+ name = models.CharField(_('name'), max_length=127)
+ email = models.EmailField(_('email'))
+ amount = models.DecimalField(_('amount'), decimal_places=2, max_digits=10)
+ payed_at = models.DateTimeField(_('payed at'))
+ perks = models.ManyToManyField(Perk, verbose_name=_('perks'), blank=True)
+ anonymous = models.BooleanField(_('anonymous'))
+
+ class Meta:
+ verbose_name = _('funding')
+ verbose_name_plural = _('fundings')
+ ordering = ['-payed_at']
+
+ def __unicode__(self):
+ return "%s payed %s for %s" % (self.name, self.amount, self.offer)
+
+
+class Spent(models.Model):
+ amount = models.DecimalField(_('amount'), decimal_places=2, max_digits=10)
+ timestamp = models.DateField(_('when'))
+ book = models.ForeignKey(Book)
+
+ class Meta:
+ verbose_name = _('money spent on a book')
+ verbose_name_plural = _('money spent on books')
+ ordering = ['-timestamp']
+
+ def __unicode__(self):
+ return u"Spent: %s" % unicode(self.book)
--- /dev/null
+a.funding{font-size:1.5em;padding:.5em 1em;display:block;color:#000;background-image:url(/static/img/green-pixel.png);background-repeat:repeat-y;background-color:rgba(13, 126, 133, .2)}.wlfund{width:100%;border-collapse:collapse}.wlfund td{padding:0 0 1em 0;text-align:center}.wlfund td:last-child{text-align:right}.wlfund td div{padding:1em;box-shadow:0 2px 0 #DDD}.wlfund .funding-plus td div{background:rgba(13, 126, 133, .2)}.wlfund .funding-minus td div{bbackground:rgba(255, 0, 0, .2);background:#fff}.funding-current{margin-bottom:3em}.funding-stale .funding{opacity:.5}
\ No newline at end of file
--- /dev/null
+a.funding {
+ font-size: 1.5em;
+ padding: .5em 1em;
+ display: block;
+ color: black;
+
+ background-image: url(/static/img/green-pixel.png);
+ background-repeat: repeat-y;
+ background-color: fade-out(#0D7E85, .8);
+}
+
+.wlfund {
+ width: 100%;
+ border-collapse: collapse;
+
+ td {
+ padding: 0 0 1em 0;
+ text-align: center;
+ }
+
+ td:last-child {
+ text-align: right;
+ }
+
+ td div {
+ padding: 1em;
+ box-shadow: 0 2px 0 #DDDDDD;
+ }
+
+ .funding-plus td div {
+ background: fade-out(#0D7E85, .8);
+ }
+
+ .funding-minus td div {
+ bbackground: fade-out(red, .8);
+ background: white;
+ }
+}
+
+
+.funding-current {
+ margin-bottom: 3em;
+}
+.funding-stale {
+ .funding {
+ opacity: .5;
+ }
+}
--- /dev/null
+{% extends "base.html" %}
+{% load url from future %}
+{% load i18n %}
+{% load funding_tags %}
+
+
+{% block titleextra %}{{ object }}{% endblock %}
+
+
+{% block body %}
+
+<h1>{{ object }}</h1>
+<div class="white-box">
+
+ {% funding object %}
+ {% offer_detail_head object %}
+
+ {% if object.state == 'running' %}
+
+ <div class="normal-text">
+
+ <h3>{% trans "Support" %}</h3>
+ <form action="" method="post">
+ {% csrf_token %}
+ <table>
+ {{ form.as_table }}
+ <tr><td></td><td><button type="submit">Wpłać!</button></td></tr>
+ </table>
+ </form>
+
+ </div>
+ {% endif %}
+
+ <p class="normal-text"><a href="{% url 'funding' %}">Zobacz wszystkie zbiórki.</a></p>
+
+</div>
+
+
+<h2 style="font-size: 3em; margin: 1em 0 .5em;">{% trans "Supporters" %}:</h2>
+
+<div class="white-box normal-text">
+
+ <table class="wlfund">
+ {% for funding in object.funding_set.all %}
+ <tr class="funding-plus">
+ <td><div>{{ funding.payed_at.date }}</div></td>
+ <td><div>
+ {% if funding.anonymous %}
+ <em>{% trans "Anonymous" %}</em>
+ {% else %}
+ {{ funding.name }}
+ {% endif %}
+ </div></td>
+ <td><div>+{{ funding.amount }} zł</div></td>
+ <td><div>
+ {% for perk in funding.perks.all %}
+ {{ perk.name }}{% if not forloop.last %},{% endif %}
+ {% endfor %}
+ </div></td>
+ {% endfor %}
+ </table>
+
+</div>
+
+{% endblock %}
--- /dev/null
+{% extends "base.html" %}
+{% load url from future %}
+{% load i18n %}
+{% load funding_tags %}
+
+{% block titleextra %}{% trans "Support Wolne Lektury" %}{% endblock %}
+
+{% block body %}
+<h1>{% trans "Support Wolne Lektury" %}</h1>
+
+<ul class="plain">
+{% for funding in object_list %}
+ <li class="white-box funding-{% if funding.is_current %}current{% else %}stale{% endif %}">
+ <p class="normal-text">{{ funding.start }} – {{ funding.end }}
+ {% if not funding.is_current %}
+ ({% trans "funding closed" %})
+ {% endif %}
+ </p>
+ {% funding funding link=1 %}
+ {% offer_detail_head funding %}
+ </li>
+{% endfor %}
+</ul>
+
+{% endblock %}
--- /dev/null
+{% load i18n %}
+{% load time_tags %}
+{% if offer %}
+<a
+ class="funding {{ add_class }}"
+ style="background-size: {{ percentage|stringformat:'.2f' }}% 1px;"
+ {% if link %}href="{{ offer.get_absolute_url }}"{% endif %}
+ >
+ {% if is_current %}
+ {% trans "Support a book:" %}
+ {% endif %}
+ <em>{{ offer }}</em>
+ <span style="float:right">
+ {% trans "collected" %}: <em>{{ offer.sum }} / {{ offer.target }} zł</em>
+ {% if is_current %}
+ <span style="margin-left: 2em;">{% trans "until fundraiser end" %}:
+ <strong class="countdown inline" data-until='{{ offer.end|local_to_utc|utc_for_js }}'></strong>
+ </span>
+ {% endif %}
+ </span>
+ <div style="clear:both"></div>
+</a>
+{% endif %}
--- /dev/null
+{% load url from future %}
+{% load i18n %}
+{% if state == "running" %}
+ <p class="normal-text">
+ {% blocktrans with due=offer.due end=offer.end %}If the target is met
+ by {{ end }}, this book will be published by {{ due }}.{% endblocktrans %}
+ </p>
+ <p class="normal-text">
+ {% url 'funding_wlfund' as url %}
+ {% blocktrans %}Any excessive money will be transfered to the
+ <a href="{{ url }}">Wolne Lektury Fund</a>.{% endblocktrans %}
+ </p>
+{% elif state == "win" %}
+ {% if offer.book %}
+ <p class="normal-text">{% trans "See the published book:" %}
+ <a href="{{ offer.book.get_absolute_url }}">{{ offer.book }}</a>.</p>
+ {% else %}
+ <p class="normal-text">{% trans "Funding target has been met!" %}</p>
+ <p class="normal-text">{% trans "The book will be published by:" %} {{ offer.due }}.
+ {% if offer.redakcja_url %}
+ {% with url=offer.redakcja_url %}
+ {% blocktrans %}You can follow the work on the <a href="{{ url }}">Editorial Platform</a>.{% endblocktrans %}
+ {% endwith %}
+ {% endif %}
+ </p>
+ {% endif %}
+{% elif state == "lose" %}
+ <p class="normal-text">{% trans "Funding target has not been met." %}
+ {% if offer.sum %}
+ {% url 'funding_wlfund' as url %}
+ {% blocktrans %}Collected funds have been transfered to the
+ <a href="{{ url }}">Wolne Lektury Fund</a>.{% endblocktrans %}
+ {% endif %}
+ </p>
+{% endif %}
--- /dev/null
+{% extends "base.html" %}
+{% load i18n %}
+{% load funding_tags %}
+
+{% block titleextra %}{% trans "Thank you!" %}{% endblock %}
+
+{% block body %}
+
+<h1>{% trans "Thank you!" %}</h1>
+<div class="white-box normal-text">
+
+{% trans "Thank you for your support!" %}
+
+<p><a href="{{ object.get_absolute_url }}">{% trans "Go back to the current fundraiser." %}</a></p>
+</div>
+
+
+{% endblock %}
--- /dev/null
+{% load i18n %}
+{% if perks %}
+ {% for perk in perks %}
+ <label>
+ <input type="radio" name="{{ perks_input_name }}" value="{{ perk.price }}"
+ {% if perk.chosen %}checked="checked"{% endif %} />
+ {{ perk.price }} zł ({{ perk.name }})
+ </label><br/>
+ {% endfor %}
+ <label>
+ <input type="radio" name="{{ perks_input_name }}" value=""
+ {% if not perk_chosen %}checked="checked"{% endif %} /> {% trans "Other amount" %}:
+ </label>
+ <input size="5" name="{{ name }}" value="{% if not perk_chosen %}{{ value|default_if_none:'' }}{% endif %}" /> zł
+{% else %}
+ <input name="{{ name }}" value="{{ value|default_if_none:'' }}" {% if value != None %}{% endif %} />
+{% endif %}
--- /dev/null
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block titleextra %}{% trans "Wolne Lektury Fund" %}{% endblock %}
+
+{% block body %}
+
+<h1>{% trans "Wolne Lektury Fund" %}</h1>
+
+
+<table class="normal-text wlfund">
+
+ <tr>
+ <td><div>{% trans "Balance" %}:</div></td>
+ <td><div> </div></td>
+ <td><div>{{ amount }} zł</div></td>
+ <td><div> </div></td>
+ </tr>
+
+ {% for tag, entry in log %}
+ {% if tag == 'spent' %}
+ <tr class="funding-minus">
+ <td><div>{{ entry.timestamp }}</div></td>
+ <td><div>-{{ entry.amount }} zł</div></td>
+ <td><div>{{ entry.total }} zł</div></td>
+ <td><div>{% trans "Book" %}: <a href="{{ entry.book.get_absolute_url }}">
+ {{ entry.book }}</a></div></td>
+ </tr>
+ {% else %}
+ <tr class="funding-plus">
+ <td><div>{{ entry.end }}</div></td>
+ <td><div>+{{ entry.wlfund }} zł</div></td>
+ <td><div>{{ entry.total }} zł</div></td>
+ <td><div>{% trans "Excessive money from fundraiser" %}:
+ <a href="{{ entry.get_absolute_url }}">
+ {{ entry }}</a></div></td>
+ </tr>
+ {% endif %}
+ {% endfor %}
+</table>
+
+
+{% endblock %}
--- /dev/null
+from django import template
+from ..models import Offer
+
+register = template.Library()
+
+
+@register.inclusion_tag("funding/tags/funding.html")
+def funding(offer=None, link=False, add_class=""):
+ if offer is None:
+ offer = Offer.current()
+ if offer is None:
+ return {}
+
+ return {
+ 'offer': offer,
+ 'is_current': offer.is_current(),
+ 'percentage': 100 * offer.sum() / offer.target,
+ 'link': link,
+ 'add_class': add_class,
+ }
+
+
+@register.inclusion_tag("funding/tags/offer_detail_head.html")
+def offer_detail_head(offer):
+ return {
+ 'offer': offer,
+ 'state': offer.state(),
+ }
+
--- /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 django.test import TestCase
+from .models import Offer, Perk, Funding
+
+
+class FundTest(TestCase):
+ def setUp(self):
+ self.offer1 = Offer.objects.create(
+ author='author1', title='title1', slug='slug1',
+ target=100, start='2013-03-01', end='2013-03-31')
+
+ 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')
+ 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.assertEqual(
+ set(self.offer1.fund('Tester', 'test@example.com', 70).perks.all()),
+ set([perk, perk1]))
--- /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 django.conf.urls import patterns, url
+from django.views.generic import ListView, FormView, TemplateView
+
+from .models import Offer
+from .views import WLFundView, OfferDetailView, ThanksView
+
+
+urlpatterns = patterns('',
+ url(r'^$', ListView.as_view(queryset=Offer.public()), name='funding'),
+ url(r'^lektura/(?P<slug>[^/]+)/$', OfferDetailView.as_view(), name='funding_offer'),
+ url(r'^dziekujemy/$', ThanksView.as_view(), name='funding_thanks'),
+ url(r'^fundusz/$', WLFundView.as_view(), name='funding_wlfund'),
+)
--- /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 django.conf import settings
+from django.core.urlresolvers import reverse
+from django.shortcuts import redirect, get_object_or_404
+from django.views.generic import TemplateView, FormView, DetailView
+from .forms import DummyForm
+from .models import Offer, Spent
+
+
+def mix(*streams):
+ substreams = []
+ for stream, read_date, tag in streams:
+ iterstream = iter(stream)
+ try:
+ item = next(iterstream)
+ except StopIteration:
+ pass
+ else:
+ substreams.append([read_date(item), item, iterstream, read_date, tag])
+ while substreams:
+ i, substream = max(enumerate(substreams), key=lambda x: x[1][0])
+ yield substream[4], substream[1]
+ try:
+ item = next(substream[2])
+ except StopIteration:
+ del substreams[i]
+ else:
+ substream[0:2] = [substream[3](item), item]
+
+
+class WLFundView(TemplateView):
+ template_name = "funding/wlfund.html"
+
+ def get_context_data(self):
+ def add_total(total, it):
+ for tag, e in it:
+ e.total = total
+ if tag == 'spent':
+ total += e.amount
+ else:
+ total -= e.wlfund
+ yield tag, e
+
+ ctx = super(WLFundView, self).get_context_data()
+ offers = []
+ for o in Offer.objects.all():
+ if o.state() == 'lose':
+ o.wlfund = o.sum()
+ if o.wlfund > 0:
+ offers.append(o)
+ elif o.state() == 'win':
+ o.wlfund = o.sum() - o.target
+ if o.wlfund > 0:
+ offers.append(o)
+ amount = sum(o.wlfund for o in offers) - sum(o.amount for o in Spent.objects.all())
+ print offers
+
+ ctx['amount'] = amount
+ ctx['log'] = add_total(amount, mix(
+ (offers, lambda x: x.end, 'offer'),
+ (Spent.objects.all(), lambda x: x.timestamp, 'spent'),
+ ))
+ return ctx
+
+
+class OfferDetailView(FormView):
+ form_class = DummyForm
+ template_name = "funding/offer_detail.html"
+
+ def dispatch(self, request, slug):
+ self.object = get_object_or_404(Offer.public(), slug=slug)
+ return super(OfferDetailView, self).dispatch(request, slug)
+
+ def get_form(self, form_class):
+ if self.request.method == 'POST':
+ return form_class(self.object, self.request.POST)
+ else:
+ return form_class(self.object, initial={'amount': settings.FUNDING_DEFAULT})
+
+ def get_context_data(self, *args, **kwargs):
+ ctx = super(OfferDetailView, self).get_context_data(*args, **kwargs)
+ ctx['object'] = self.object
+ return ctx
+
+ def form_valid(self, form):
+ form.save()
+ return redirect(reverse("funding_thanks"))
+
+
+class ThanksView(TemplateView):
+ template_name = "funding/thanks.html"
+
+ def get_context_data(self, *args, **kwargs):
+ ctx = super(ThanksView, self).get_context_data(*args, **kwargs)
+ ctx['object'] = Offer.current()
+ return ctx
--- /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 decimal import Decimal
+from django.conf import settings
+from django import forms
+from django.template.loader import render_to_string
+
+
+class PerksAmountWidget(forms.Textarea):
+ def perks_input_name(self, name):
+ return "_%s_perk" % name
+
+ def render(self, name, value, attrs=None):
+ try:
+ value = Decimal(value)
+ except:
+ pass
+ perks = list(self.form_instance.offer.get_perks())
+ perk_chosen = False
+ for perk in perks:
+ if perk.price == value:
+ perk.chosen = True
+ perk_chosen = True
+ break
+
+ return render_to_string("funding/widgets/amount.html", {
+ "perks": perks,
+ "name": name,
+ "perks_input_name": self.perks_input_name(name),
+ "perk_chosen": perk_chosen,
+ "value": value,
+ "attrs": attrs,
+ })
+
+ def value_from_datadict(self, data, files, name):
+ num_str = data.get(self.perks_input_name(name)) or data[name]
+ return num_str.replace(',', '.')
+
+
from django.db.models import Q
from django.conf import settings
from django.contrib.sites.models import Site
+from django.utils import timezone
WL_DC_READER_XPATH = '(.|*)/rdf:RDF/rdf:Description/%s/text()'
self.oai_id = "oai:" + Site.objects.get_current().domain + ":%s"
# earliest change
- year_zero = datetime(1990, 1, 1, 0, 0, 0)
+ year_zero = timezone.make_aware(datetime(1990, 1, 1, 0, 0, 0), timezone.utc)
try:
earliest_change = \
(function($) {
$(function() {
-
- $('#countdown').each(function() {
+ $('.countdown').each(function() {
var $this = $(this);
var serverTime = function() {
$.countdown.setDefaults($.countdown.regional['']);
}
- var d = new Date($this.attr('data-year'), 0, 1);
- function re() {location.reload()};
- $this.countdown({until: d, format: 'ydHMS', serverSync: serverTime,
- onExpiry: re, alwaysExpire: true});
-
+ var options = {
+ until: new Date($this.attr('data-until')),
+ format: 'ydHMS',
+ serverSync: serverTime,
+ onExpiry: function(){location.reload()}, // TODO: no reload
+ };
+ if ($this.hasClass('inline')) {
+ options.layout = '{dn} {dl} {hnn}{sep}{mnn}{sep}{snn}';
+ }
+
+ $this.countdown(options);
});
});
-})(jQuery);
\ No newline at end of file
+})(jQuery);
{% extends "base.html" %}
{% load i18n %}
+{% load time_tags %}
{% block titleextra %}{{ author.name }}{% endblock %}
{% else %}
<div>
<p>{% trans "This author's works will become part of public domain and will be allowed to be published without restrictions in" %}</p>
- <div id='countdown' data-year='{{ pd_counter }}'></div>
+ <div class='countdown' data-until='{{ pd_counter|local_to_utc|utc_for_js }}'></div>
<p>{% trans "<a href='http://domenapubliczna.org/co-to-jest-domena-publiczna/'>Find out</a> why Internet libraries can't publish this author's works." %}</p>
</div>
{% endif %}
{% extends "base.html" %}
{% load i18n %}
+{% load time_tags %}
{% block titleextra %}{{ book.title }}{% endblock %}
{% else %}
{% if book.pd %}
<p>{% trans "This work will become part of public domain and will be allowed to be published without restrictions in" %}</p>
- <div id='countdown' data-year='{{ pd_counter }}'></div>
+ <div class='countdown' data-until='{{ pd_counter|local_to_utc|utc_for_js }}'></div>
<p>{% trans "<a href='http://domenapubliczna.org/co-to-jest-domena-publiczna/'>Find out</a> why Internet libraries can't publish this work." %}</p>
{% else %}
<p>{% trans "This work is copyrighted." %}
--- /dev/null
+import datetime
+import pytz
+from django.conf import settings
+from django import template
+from django.utils import timezone
+
+
+register = template.Library()
+
+@register.filter
+def local_to_utc(localtime):
+ if isinstance(localtime, datetime.date):
+ localtime = datetime.datetime.combine(localtime, datetime.time(0,0))
+ return timezone.utc.normalize(
+ pytz.timezone(settings.TIME_ZONE).localize(localtime)
+ )
+
+
+@register.filter
+def utc_for_js(dt):
+ return dt.strftime('%Y/%m/%d %H:%M:%S UTC')
# 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 datetime
-
+from datetime import datetime
from django.template import RequestContext
from django.shortcuts import render_to_response, get_object_or_404
from pdcounter import models
def book_stub_detail(request, slug):
book = get_object_or_404(models.BookStub, slug=slug)
- pd_counter = book.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 = author.goes_to_pd()
+ pd_counter = datetime(author.goes_to_pd(), 1, 1)
form = PublishingSuggestForm(initial={"books": author.name + ", \n"})
--- /dev/null
+form table th{vertical-align:top;text-align:left;font-weight:normal}form table td{padding-bottom:1em}form table .required th:after{content:" *"}form table .errorlist{color:red;margin:0;padding:0;list-style:none}form table .helptext{color:#888;font-size:.9em;font-style:italic}
\ No newline at end of file
--- /dev/null
+form table {
+ th {
+ vertical-align: top;
+ text-align: left;
+ font-weight: normal;
+ }
+ td {
+ padding-bottom: 1em;
+ }
+
+ .required th:after {
+ content: " *";
+ }
+
+ .errorlist {
+ color: red;
+ margin: 0;
+ padding: 0;
+ list-style: none;
+ }
+ .helptext {
+ color: #888;
+ font-size: .9em;
+ font-style: italic;
+ }
+}
color: #989898;
}
+#logo a, #logo img {
+ display: block;
+}
#tagline {
margin-left: 1.5em;
<html lang="{{ LANGUAGE_CODE }}" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#">
{% load cache compressed i18n %}
{% load static from staticfiles %}
- {% load catalogue_tags reporting_stats sponsor_tags %}
+ {% load catalogue_tags funding_tags reporting_stats sponsor_tags %}
<head>
<meta charset="utf-8">
<meta name="application-name" content="Wolne Lektury" />
</div>
-
<div id="main-content">
-
+ {% funding link=1 %}
<div id="nav-line">
{% catalogue_menu %}
def clock(request):
- """ Provides server time for jquery.countdown,
+ """ Provides server UTC time for jquery.countdown,
in a format suitable for Date.parse()
"""
- return HttpResponse(datetime.now().strftime('%Y/%m/%d %H:%M:%S'))
+ return HttpResponse(datetime.utcnow().strftime('%Y/%m/%d %H:%M:%S UTC'))
def publish_plan(request):
--- /dev/null
+from os.path import dirname
+from django.conf import settings
+from pipeline.compilers import SubProcessCompiler
+
+
+class PySCSSCompiler(SubProcessCompiler):
+ output_extension = 'css'
+
+ def match_file(self, filename):
+ return filename.endswith('.scss')
+
+ def compile_file(self, infile, outfile, outdated=False, force=False):
+ command = "%s %s < %s > %s" % (
+ settings.PIPELINE_PYSCSS_BINARY,
+ settings.PIPELINE_PYSCSS_ARGUMENTS,
+ infile,
+ outfile
+ )
+ return self.execute_command(command, cwd=dirname(infile))
Django>=1.5,<1.6
fnpdjango>=0.1.6,<0.2
South>=0.7 # migrations for django
-django-pipeline>=1.2,<1.3
+django-pipeline>=1.2.24,<1.3
django-pagination>=1.0
django-maintenancemode>=0.10
django-piston>=0.2.2.1,<0.2.3
#django-allauth<0.10 with migration fix
-e git+git://github.com/rczajka/django-allauth.git@4ecda71b81f9311dea4febe1d2d0105f23c642c7#egg=django-allauth
+pytz
+pyScss
+
# Some contrib apps still need it
simplejson
'waiter',
'search',
'oai',
+ 'funding',
]
INSTALLED_APPS_CONTRIB = [
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'Europe/Warsaw'
+USE_TZ = True
SITE_ID = 1
# set to 'new' or 'old' to skip time-consuming test
# for TeX morefloats library version
LIBRARIAN_PDF_MOREFLOATS = None
+
+FUNDING_DEFAULT = 20
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
+USE_L10N = True
LOCALE_PATHS = [
path.join(PROJECT_DIR, 'locale-contrib')
'css/catalogue.css',
'sponsors/css/sponsors.css',
'css/auth.css',
+ 'funding/funding.scss',
+ 'css/form.scss',
'css/social/shelf_tags.css',
'css/ui-lightness/jquery-ui-1.8.16.custom.css',
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
PIPELINE_CSS_COMPRESSOR = None
PIPELINE_JS_COMPRESSOR = None
+
+PIPELINE_COMPILERS = (
+ 'pyscss_compiler.PySCSSCompiler',
+)
+PIPELINE_PYSCSS_BINARY = '/usr/bin/env pyscss'
+PIPELINE_PYSCSS_ARGUMENTS = ''
url(r'^ludzie/', include('social.urls')),
url(r'^uzytkownik/', include('allauth.urls')),
url(r'^czekaj/', include('waiter.urls')),
+ url(r'^fund/', include('funding.urls')),
# Admin panel
url(r'^admin/catalogue/book/import$', 'catalogue.views.import_book', name='import_book'),
--- /dev/null
+import pytz
+from django.utils import timezone
+from django.conf import settings
+
+def localtime_to_utc(localtime):
+ return timezone.utc.normalize(
+ pytz.timezone(settings.TIME_ZONE).localize(localtime)
+ )
+
+def utc_for_js(dt):
+ return dt.strftime('%Y/%m/%d %H:%M:%S UTC')