Browse Source

PIN can now be deleted in admin interface and preparation for hashing of PIN

master
Niklas Brachmann 11 years ago
parent
commit
d5bcc7d55e
  1. 22
      cash/admin.py
  2. 90
      cash/locale/de/LC_MESSAGES/django.po
  3. 8
      cash/models.py

22
cash/admin.py

@ -10,11 +10,17 @@ from django.utils.translation import ugettext_noop
class AccountForm(forms.ModelForm): class AccountForm(forms.ModelForm):
credit_change = forms.DecimalField(max_digits=5, decimal_places=2, credit_change = forms.DecimalField(max_digits=5, decimal_places=2,
required=False, required=False,
label=ugettext_lazy('credit change')) label=ugettext_lazy('amount'))
credit_change_comment = forms.CharField(max_length=64, required=False, credit_change_comment = forms.CharField(max_length=64, required=False,
label=ugettext_lazy('comment')) 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: class Meta:
model = Account model = Account
@ -24,11 +30,14 @@ class AccountAdmin(admin.ModelAdmin):
readonly_fields = ('credit',) readonly_fields = ('credit',)
fieldsets = ( fieldsets = (
(None, { (None, {
'fields': ('user', 'card_number', 'pin', 'credit'), 'fields': ('user', 'card_number', 'credit'),
}), }),
(ugettext_lazy('credit change'), { (ugettext_lazy('credit change'), {
'fields': ('credit_change', 'credit_change_comment'), 'fields': ('credit_change', 'credit_change_comment'),
}), }),
(ugettext_lazy('change PIN'), {
'fields': ('pin_change', 'pin_empty'),
}),
) )
def transaction_link(self, account): def transaction_link(self, account):
@ -41,6 +50,15 @@ class AccountAdmin(admin.ModelAdmin):
transaction_link.allow_tags = True transaction_link.allow_tags = True
def save_model(self, request, obj, form, change): 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') PAYOUT_SUBJECT = ugettext_noop('Payout')
DEPOSIT_SUBJECT = ugettext_noop('Deposit') DEPOSIT_SUBJECT = ugettext_noop('Deposit')
DESCRIPTION = ugettext_noop('Authorized by %(first)s %(last)s') DESCRIPTION = ugettext_noop('Authorized by %(first)s %(last)s')

90
cash/locale/de/LC_MESSAGES/django.po

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -18,31 +18,47 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n"
#: admin.py:13 admin.py:29 #: admin.py:13 models.py:138 management/commands/dailydigest.py:40
msgid "credit change" msgid "amount"
msgstr "Ein-/Auszahlung" msgstr "Betrag"
#: admin.py:16 models.py:84 models.py:113 #: admin.py:16 models.py:92 models.py:121
msgid "comment" msgid "comment"
msgstr "Kommentar" 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" msgid "Transactions"
msgstr "Transaktionen" msgstr "Transaktionen"
#: admin.py:39 #: admin.py:48
msgid "Transaction link" msgid "Transaction link"
msgstr "Transaktionslink" msgstr "Transaktionslink"
#: admin.py:44 #: admin.py:62
msgid "Payout" msgid "Payout"
msgstr "Auszahlung" msgstr "Auszahlung"
#: admin.py:45 #: admin.py:63
msgid "Deposit" msgid "Deposit"
msgstr "Einzahlung" msgstr "Einzahlung"
#: admin.py:46 #: admin.py:64
#, python-format #, python-format
msgid "Authorized by %(first)s %(last)s" msgid "Authorized by %(first)s %(last)s"
msgstr "Autorisiert von %(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" msgid "card number"
msgstr "Kartennummer" msgstr "Kartennummer"
#: models.py:14 views.py:81
msgid "PIN"
msgstr "PIN"
#: models.py:15 views.py:77 templates/cash/usersettings.html:10 #: models.py:15 views.py:77 templates/cash/usersettings.html:10
msgid "daily digest" msgid "daily digest"
msgstr "Tägliche Zusammenfassung" msgstr "Tägliche Zusammenfassung"
@ -63,7 +75,7 @@ msgstr "Tägliche Zusammenfassung"
msgid "credit" msgid "credit"
msgstr "Guthaben" msgstr "Guthaben"
#: models.py:23 models.py:124 models.py:137 #: models.py:23 models.py:132 models.py:145
msgid "account" msgid "account"
msgstr "Konto" msgstr "Konto"
@ -75,87 +87,83 @@ msgstr "Konten"
msgid "Purchase" msgid "Purchase"
msgstr "Einkauf" msgstr "Einkauf"
#: models.py:82 models.py:95 #: models.py:90 models.py:103
msgid "name" msgid "name"
msgstr "Name" msgstr "Name"
#: models.py:90 #: models.py:98
msgid "product category" msgid "product category"
msgstr "Produktkategorie" msgstr "Produktkategorie"
#: models.py:91 #: models.py:99
msgid "product categories" msgid "product categories"
msgstr "Produktkategorien" msgstr "Produktkategorien"
#: models.py:97 templates/cash/product_list.html:19 #: models.py:105 templates/cash/product_list.html:19
msgid "price" msgid "price"
msgstr "Preis" msgstr "Preis"
#: models.py:98 #: models.py:106
msgid "active" msgid "active"
msgstr "Aktiv" msgstr "Aktiv"
#: models.py:100 #: models.py:108
msgid "category" msgid "category"
msgstr "Kategorie" msgstr "Kategorie"
#: models.py:106 models.py:114 models.py:138 #: models.py:114 models.py:122 models.py:146
msgid "product" msgid "product"
msgstr "Produkt" msgstr "Produkt"
#: models.py:107 #: models.py:115
msgid "products" msgid "products"
msgstr "Produkte" msgstr "Produkte"
#: models.py:111 models.py:120 #: models.py:119 models.py:128
msgid "barcode" msgid "barcode"
msgstr "Strichcode" msgstr "Strichcode"
#: models.py:121 #: models.py:129
msgid "barcodes" msgid "barcodes"
msgstr "Strichcodes" msgstr "Strichcodes"
#: models.py:126 models.py:143 #: models.py:134 models.py:151
msgid "timestamp" msgid "timestamp"
msgstr "Zeitstempel" msgstr "Zeitstempel"
#: models.py:127 management/commands/dailydigest.py:33 #: models.py:135 management/commands/dailydigest.py:39
msgid "subject" msgid "subject"
msgstr "Betreff" msgstr "Betreff"
#: models.py:128 #: models.py:136
msgid "description" msgid "description"
msgstr "Beschreibung" msgstr "Beschreibung"
#: models.py:130 management/commands/dailydigest.py:33 #: models.py:141
msgid "amount"
msgstr "Betrag"
#: models.py:133
msgid "transaction" msgid "transaction"
msgstr "Transaktion" msgstr "Transaktion"
#: models.py:134 #: models.py:142
msgid "transactions" msgid "transactions"
msgstr "Transaktionen" msgstr "Transaktionen"
#: models.py:139 #: models.py:147
msgid "count" msgid "count"
msgstr "Anzahl" msgstr "Anzahl"
#: models.py:141 #: models.py:149
msgid "unit price" msgid "unit price"
msgstr "Stückpreis" msgstr "Stückpreis"
#: models.py:146 #: models.py:154
msgid "sales log entry" msgid "sales log entry"
msgstr "Verkaufsprotokolleintrag" msgstr "Verkaufsprotokolleintrag"
#: models.py:147 #: models.py:155
msgid "sales log entries" msgid "sales log entries"
msgstr "Verkaufsprotokolleinträge" msgstr "Verkaufsprotokolleinträge"
#: models.py:151 #: models.py:159
msgid "Cancellation" msgid "Cancellation"
msgstr "Stornierung" msgstr "Stornierung"
@ -167,11 +175,11 @@ msgstr "PIN (bestätigen)"
msgid "PINs do not match." msgid "PINs do not match."
msgstr "PINs stimmen nicht überein." msgstr "PINs stimmen nicht überein."
#: management/commands/dailydigest.py:33 #: management/commands/dailydigest.py:38
msgid "date" msgid "date"
msgstr "Datum" msgstr "Datum"
#: management/commands/dailydigest.py:48 #: management/commands/dailydigest.py:64
msgid "Account Statement" msgid "Account Statement"
msgstr "Kontoauszug" msgstr "Kontoauszug"

8
cash/models.py

@ -76,6 +76,14 @@ class Account(models.Model):
def buy_product(self, product, amount=1): def buy_product(self, product, amount=1):
return self.buy_products({product: amount}) 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): class ProductCategory(models.Model):
name = models.CharField(max_length=32, unique=True, name = models.CharField(max_length=32, unique=True,

Loading…
Cancel
Save