From: Radek Czajka Date: Fri, 2 Aug 2013 12:03:15 +0000 (+0200) Subject: fixes #2930: info about perks in admin. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/b78791b6c6ace71524e767f9d1a527972e5ba338?ds=inline;hp=-c fixes #2930: info about perks in admin. --- b78791b6c6ace71524e767f9d1a527972e5ba338 diff --git a/apps/funding/admin.py b/apps/funding/admin.py index c8a25d013..d70aef66a 100644 --- a/apps/funding/admin.py +++ b/apps/funding/admin.py @@ -2,6 +2,7 @@ # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # +from django.utils.translation import ugettext_lazy as _ from django.contrib import admin from .models import Offer, Perk, Funding, Spent @@ -15,13 +16,47 @@ class OfferAdmin(admin.ModelAdmin): 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/locale/pl/LC_MESSAGES/django.mo b/apps/funding/locale/pl/LC_MESSAGES/django.mo index dbd447131..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 c3cb1438f..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-07-26 10:00+0200\n" -"PO-Revision-Date: 2013-07-30 14:26+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,6 +19,22 @@ msgstr "" "|| n%100>=20) ? 1 : 2);\n" "X-Generator: Poedit 1.5.4\n" +#: 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" @@ -111,7 +128,7 @@ msgstr "Wysłano powiadomienia o zakończeniu" msgid "Cover preview" msgstr "Podgląd okładki" -#: models.py:45 models.py:186 models.py:207 +#: models.py:45 models.py:189 models.py:210 msgid "offer" msgstr "zbiórka" @@ -119,79 +136,75 @@ msgstr "zbiórka" msgid "offers" msgstr "zbiórki" -#: models.py:141 +#: models.py:144 msgid "The fundraiser has ended!" msgstr "Zbiórka dobiegła końca!" -#: models.py:157 +#: models.py:160 msgid "The fundraiser will end soon!" msgstr "Zbiórka niedługo się zakończy!" -#: models.py:171 +#: 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:187 +#: models.py:190 msgid "price" msgstr "cena" -#: models.py:188 models.py:208 +#: models.py:191 models.py:211 msgid "name" msgstr "nazwa" -#: models.py:189 +#: models.py:192 msgid "long name" msgstr "długa nazwa" -#: models.py:190 +#: models.py:193 msgid "end date" msgstr "data końcowa" -#: models.py:193 +#: models.py:196 msgid "perk" msgstr "prezent" -#: models.py:194 models.py:212 -msgid "perks" -msgstr "prezenty" - -#: models.py:209 +#: models.py:212 msgid "email" msgstr "e-mail" -#: models.py:210 models.py:287 +#: models.py:213 models.py:293 msgid "amount" msgstr "kwota" -#: models.py:211 +#: models.py:214 msgid "payed at" msgstr "data wpłaty" -#: models.py:214 +#: models.py:217 msgid "notifications" msgstr "powiadomienia" -#: models.py:218 +#: models.py:221 msgid "funding" msgstr "wpłata" -#: models.py:219 templates/admin/funding/offer/change_form.html:22 +#: models.py:222 templates/admin/funding/offer/change_form.html:22 msgid "fundings" msgstr "wpłaty" -#: models.py:288 +#: models.py:294 msgid "when" msgstr "kiedy" -#: models.py:291 +#: models.py:297 msgid "money spent on a book" msgstr "pieniądze wydane na książkę" -#: models.py:292 +#: models.py:298 msgid "money spent on books" msgstr "pieniądze wydane na książki" -#: models.py:318 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!" diff --git a/apps/funding/models.py b/apps/funding/models.py index 0bd5360f9..de52ac9d8 100644 --- a/apps/funding/models.py +++ b/apps/funding/models.py @@ -233,6 +233,9 @@ class Funding(models.Model): 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({