Some preparation for upgrade.
[wolnelektury.git] / src / club / admin.py
1 from django.contrib import admin
2 from modeltranslation.admin import TranslationAdmin
3 from . import models
4
5
6 class PlanAdmin(admin.ModelAdmin):
7     list_display = ['min_amount', 'interval']
8
9 admin.site.register(models.Plan, PlanAdmin)
10
11
12 class PayUOrderInline(admin.TabularInline):
13     model = models.PayUOrder
14     extra = 0
15     show_change_link = True
16
17
18 class PayUCardTokenInline(admin.TabularInline):
19     model = models.PayUCardToken
20     extra = 0
21     show_change_link = True
22
23
24 class ScheduleAdmin(admin.ModelAdmin):
25     list_display = ['email', 'started_at', 'expires_at', 'plan', 'amount', 'is_cancelled']
26     list_search = ['email']
27     list_filter = ['is_cancelled']
28     date_hierarchy = 'started_at'
29     raw_id_fields = ['membership']
30     inlines = [PayUOrderInline, PayUCardTokenInline]
31
32 admin.site.register(models.Schedule, ScheduleAdmin)
33
34
35 class ScheduleInline(admin.TabularInline):
36     model = models.Schedule
37     extra = 0
38     show_change_link = True
39
40 class MembershipAdmin(admin.ModelAdmin):
41     list_display = ['user']
42     raw_id_fields = ['user']
43     search_fields = ['user__username', 'user__email']
44     inlines = [ScheduleInline]
45
46 admin.site.register(models.Membership, MembershipAdmin)
47
48
49 admin.site.register(models.ReminderEmail, TranslationAdmin)
50
51
52 admin.site.register(models.PayUNotification)