Add app for PZ.
[wolnelektury.git] / src / pz / admin.py
diff --git a/src/pz/admin.py b/src/pz/admin.py
new file mode 100644 (file)
index 0000000..8677931
--- /dev/null
@@ -0,0 +1,52 @@
+from django.contrib import admin
+from django.utils.translation import gettext_lazy as _
+from . import models
+
+
+admin.site.register(models.Fundraiser)
+admin.site.register(models.Campaign)
+
+@admin.register(models.DirectDebit)
+class DirectDebitAdmin(admin.ModelAdmin):
+    list_display = ['acquisition_date', 'amount', 'first_name', 'last_name']
+    fieldsets = [
+        (None, {
+            "fields": [
+                ('first_name', 'sex', 'date_of_birth'),
+                'last_name',
+                ('street', 'building'),
+                ('town', 'flat'),
+                ('postal_code', 'phone'),
+                'email',
+                'iban',
+                'payment_id',
+                'agree_contact',
+                'agree_fundraising',
+                'agree_newsletter',
+                ('acquisition_date', 'amount'),
+                'is_consumer',
+                'fundraiser',
+                'campaign',
+            ]
+        }),
+        (_('Processing'), {"fields": [
+            ('is_cancelled', 'needs_redo', 'optout'),
+            'submission_date',
+            'fundraiser_commission',
+            'fundraiser_bill',
+            'bank_submission_date',
+            'bank_acceptance_date',
+            'notes',
+            ]
+        })
+    ]
+    readonly_fields = ['agree_contact']
+
+    def agree_contact(self, obj):
+        return _('obligatory')
+    agree_contact.short_description = _('agree contact')
+
+    def get_changeform_initial_data(self, request):
+        return {
+            'payment_id': models.DirectDebit.get_next_payment_id(),
+        }