diff --git a/cash/admin.py b/cash/admin.py index fd73abd..d8997a2 100644 --- a/cash/admin.py +++ b/cash/admin.py @@ -10,11 +10,17 @@ from django.utils.translation import ugettext_noop class AccountForm(forms.ModelForm): credit_change = forms.DecimalField(max_digits=5, decimal_places=2, required=False, - label=ugettext_lazy('credit change')) + label=ugettext_lazy('amount')) credit_change_comment = forms.CharField(max_length=64, required=False, label=ugettext_lazy('comment')) + pin_change = forms.RegexField(regex='^\d{4,}$', required=False, + label=ugettext_lazy('PIN')) + + pin_empty = forms.BooleanField(required=False, + label=ugettext_lazy('clear PIN')) + class Meta: model = Account @@ -24,11 +30,14 @@ class AccountAdmin(admin.ModelAdmin): readonly_fields = ('credit',) fieldsets = ( (None, { - 'fields': ('user', 'card_number', 'pin', 'credit'), + 'fields': ('user', 'card_number', 'credit'), }), (ugettext_lazy('credit change'), { 'fields': ('credit_change', 'credit_change_comment'), }), + (ugettext_lazy('change PIN'), { + 'fields': ('pin_change', 'pin_empty'), + }), ) def transaction_link(self, account): @@ -41,6 +50,15 @@ class AccountAdmin(admin.ModelAdmin): transaction_link.allow_tags = True def save_model(self, request, obj, form, change): + pin = form.cleaned_data['pin_change'] + pin_empty = form.cleaned_data['pin_empty'] + + if pin_empty: + obj.clear_pin() + else: + if pin is not None and len(pin) != 0: + obj.set_pin(pin) + PAYOUT_SUBJECT = ugettext_noop('Payout') DEPOSIT_SUBJECT = ugettext_noop('Deposit') DESCRIPTION = ugettext_noop('Authorized by %(first)s %(last)s') diff --git a/cash/locale/de/LC_MESSAGES/django.po b/cash/locale/de/LC_MESSAGES/django.po index b471497..2af19db 100644 --- a/cash/locale/de/LC_MESSAGES/django.po +++ b/cash/locale/de/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-09-15 21:30+0200\n" +"POT-Creation-Date: 2013-09-18 00:00+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,31 +18,47 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -#: admin.py:13 admin.py:29 -msgid "credit change" -msgstr "Ein-/Auszahlung" +#: admin.py:13 models.py:138 management/commands/dailydigest.py:40 +msgid "amount" +msgstr "Betrag" -#: admin.py:16 models.py:84 models.py:113 +#: admin.py:16 models.py:92 models.py:121 msgid "comment" msgstr "Kommentar" -#: admin.py:37 +#: admin.py:19 models.py:14 views.py:81 +msgid "PIN" +msgstr "PIN" + +#: admin.py:22 +msgid "clear PIN" +msgstr "PIN löschen" + +#: admin.py:35 +msgid "credit change" +msgstr "Ein-/Auszahlung" + +#: admin.py:38 +msgid "change PIN" +msgstr "PIN ändern" + +#: admin.py:46 msgid "Transactions" msgstr "Transaktionen" -#: admin.py:39 +#: admin.py:48 msgid "Transaction link" msgstr "Transaktionslink" -#: admin.py:44 +#: admin.py:62 msgid "Payout" msgstr "Auszahlung" -#: admin.py:45 +#: admin.py:63 msgid "Deposit" msgstr "Einzahlung" -#: admin.py:46 +#: admin.py:64 #, python-format msgid "Authorized by %(first)s %(last)s" msgstr "Autorisiert von %(first)s %(last)s" @@ -51,10 +67,6 @@ msgstr "Autorisiert von %(first)s %(last)s" msgid "card number" msgstr "Kartennummer" -#: models.py:14 views.py:81 -msgid "PIN" -msgstr "PIN" - #: models.py:15 views.py:77 templates/cash/usersettings.html:10 msgid "daily digest" msgstr "Tägliche Zusammenfassung" @@ -63,7 +75,7 @@ msgstr "Tägliche Zusammenfassung" msgid "credit" msgstr "Guthaben" -#: models.py:23 models.py:124 models.py:137 +#: models.py:23 models.py:132 models.py:145 msgid "account" msgstr "Konto" @@ -75,87 +87,83 @@ msgstr "Konten" msgid "Purchase" msgstr "Einkauf" -#: models.py:82 models.py:95 +#: models.py:90 models.py:103 msgid "name" msgstr "Name" -#: models.py:90 +#: models.py:98 msgid "product category" msgstr "Produktkategorie" -#: models.py:91 +#: models.py:99 msgid "product categories" msgstr "Produktkategorien" -#: models.py:97 templates/cash/product_list.html:19 +#: models.py:105 templates/cash/product_list.html:19 msgid "price" msgstr "Preis" -#: models.py:98 +#: models.py:106 msgid "active" msgstr "Aktiv" -#: models.py:100 +#: models.py:108 msgid "category" msgstr "Kategorie" -#: models.py:106 models.py:114 models.py:138 +#: models.py:114 models.py:122 models.py:146 msgid "product" msgstr "Produkt" -#: models.py:107 +#: models.py:115 msgid "products" msgstr "Produkte" -#: models.py:111 models.py:120 +#: models.py:119 models.py:128 msgid "barcode" msgstr "Strichcode" -#: models.py:121 +#: models.py:129 msgid "barcodes" msgstr "Strichcodes" -#: models.py:126 models.py:143 +#: models.py:134 models.py:151 msgid "timestamp" msgstr "Zeitstempel" -#: models.py:127 management/commands/dailydigest.py:33 +#: models.py:135 management/commands/dailydigest.py:39 msgid "subject" msgstr "Betreff" -#: models.py:128 +#: models.py:136 msgid "description" msgstr "Beschreibung" -#: models.py:130 management/commands/dailydigest.py:33 -msgid "amount" -msgstr "Betrag" - -#: models.py:133 +#: models.py:141 msgid "transaction" msgstr "Transaktion" -#: models.py:134 +#: models.py:142 msgid "transactions" msgstr "Transaktionen" -#: models.py:139 +#: models.py:147 msgid "count" msgstr "Anzahl" -#: models.py:141 +#: models.py:149 msgid "unit price" msgstr "Stückpreis" -#: models.py:146 +#: models.py:154 msgid "sales log entry" msgstr "Verkaufsprotokolleintrag" -#: models.py:147 +#: models.py:155 msgid "sales log entries" msgstr "Verkaufsprotokolleinträge" -#: models.py:151 +#: models.py:159 msgid "Cancellation" msgstr "Stornierung" @@ -167,11 +175,11 @@ msgstr "PIN (bestätigen)" msgid "PINs do not match." msgstr "PINs stimmen nicht überein." -#: management/commands/dailydigest.py:33 +#: management/commands/dailydigest.py:38 msgid "date" msgstr "Datum" -#: management/commands/dailydigest.py:48 +#: management/commands/dailydigest.py:64 msgid "Account Statement" msgstr "Kontoauszug" diff --git a/cash/models.py b/cash/models.py index 7acbaab..e7fa353 100644 --- a/cash/models.py +++ b/cash/models.py @@ -76,6 +76,14 @@ class Account(models.Model): def buy_product(self, product, amount=1): return self.buy_products({product: amount}) + def set_pin(self, pin): + # TODO: hash pin + self.pin = pin + self.save() + + def clear_pin(self): + self.pin = '' + self.save() class ProductCategory(models.Model): name = models.CharField(max_length=32, unique=True,