86779316c5c914a8442e9cb946b6db26b2ff97b7
[wolnelektury.git] / src / pz / admin.py
1 from django.contrib import admin
2 from django.utils.translation import gettext_lazy as _
3 from . import models
4
5
6 admin.site.register(models.Fundraiser)
7 admin.site.register(models.Campaign)
8
9 @admin.register(models.DirectDebit)
10 class DirectDebitAdmin(admin.ModelAdmin):
11     list_display = ['acquisition_date', 'amount', 'first_name', 'last_name']
12     fieldsets = [
13         (None, {
14             "fields": [
15                 ('first_name', 'sex', 'date_of_birth'),
16                 'last_name',
17                 ('street', 'building'),
18                 ('town', 'flat'),
19                 ('postal_code', 'phone'),
20                 'email',
21                 'iban',
22                 'payment_id',
23                 'agree_contact',
24                 'agree_fundraising',
25                 'agree_newsletter',
26                 ('acquisition_date', 'amount'),
27                 'is_consumer',
28                 'fundraiser',
29                 'campaign',
30             ]
31         }),
32         (_('Processing'), {"fields": [
33             ('is_cancelled', 'needs_redo', 'optout'),
34             'submission_date',
35             'fundraiser_commission',
36             'fundraiser_bill',
37             'bank_submission_date',
38             'bank_acceptance_date',
39             'notes',
40             ]
41         })
42     ]
43     readonly_fields = ['agree_contact']
44
45     def agree_contact(self, obj):
46         return _('obligatory')
47     agree_contact.short_description = _('agree contact')
48
49     def get_changeform_initial_data(self, request):
50         return {
51             'payment_id': models.DirectDebit.get_next_payment_id(),
52         }