1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django.contrib import admin
6 from django.utils.html import conditional_escape
7 from django.utils.safestring import mark_safe
8 from modeltranslation.admin import TranslationAdmin
12 admin.site.register(models.Club)
15 class PayUOrderInline(admin.TabularInline):
16 model = models.PayUOrder
17 fields = ['order_id', 'status', 'customer_ip']
18 readonly_fields = fields
20 show_change_link = True
23 def has_add_permission(self, request, obj):
27 class PayUCardTokenInline(admin.TabularInline):
28 model = models.PayUCardToken
29 fields = ['created_at', 'disposable_token', 'reusable_token']
30 readonly_fields = fields
32 show_change_link = True
34 show_change_link = True
36 def has_add_permission(self, request, obj):
40 class ScheduleAdmin(admin.ModelAdmin):
41 list_display = ['email', 'started_at', 'payed_at', 'expires_at', 'amount', 'monthly', 'yearly', 'is_cancelled']
42 search_fields = ['email']
43 list_filter = ['is_cancelled']
44 date_hierarchy = 'started_at'
45 raw_id_fields = ['membership']
46 inlines = [PayUOrderInline, PayUCardTokenInline]
48 admin.site.register(models.Schedule, ScheduleAdmin)
51 class ScheduleInline(admin.TabularInline):
52 model = models.Schedule
53 fields = ['email', 'amount', 'is_cancelled', 'started_at', 'payed_at', 'expires_at', 'email_sent']
54 readonly_fields = fields
56 show_change_link = True
59 def has_add_permission(self, request, obj):
63 class MembershipAdmin(admin.ModelAdmin):
64 list_display = ['user']
65 raw_id_fields = ['user']
66 search_fields = ['user__username', 'user__email', 'schedule__email']
67 inlines = [ScheduleInline]
69 admin.site.register(models.Membership, MembershipAdmin)
72 admin.site.register(models.ReminderEmail, TranslationAdmin)
75 class PayUNotificationAdmin(admin.ModelAdmin):
76 list_display = ['received_at', 'order']
77 fields = ['received_at', 'order', 'body_']
78 readonly_fields = ['received_at', 'body_']
79 raw_id_fields = ['order']
84 conditional_escape(json.dumps(json.loads(obj.body), indent=4))
88 admin.site.register(models.PayUNotification, PayUNotificationAdmin)
91 class PayUNotificationInline(admin.TabularInline):
92 model = models.PayUNotification
93 fields = ['received_at', 'body_']
94 readonly_fields = fields
96 show_change_link = True
102 conditional_escape(json.dumps(json.loads(obj.body), indent=4))
105 def has_add_permission(self, request, obj):
109 class PayUOrderAdmin(admin.ModelAdmin):
110 list_display = ['schedule']
111 raw_id_fields = ['schedule']
112 inlines = [PayUNotificationInline]
115 admin.site.register(models.PayUOrder, PayUOrderAdmin)
118 admin.site.register(models.Ambassador)