-
Notifications
You must be signed in to change notification settings - Fork 2
/
admin.py
91 lines (76 loc) · 2.64 KB
/
admin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# coding: utf-8
from quokka import admin
from quokka.core.admin.models import ModelAdmin, BaseContentAdmin
from quokka.core.admin import _, _l
from quokka.core.widgets import TextEditor, PrepopulatedText
from .models import Course, CourseSubscription, Subscriber
class CourseAdmin(BaseContentAdmin):
column_searchable_list = ('title', 'description', 'summary')
form_args = {
"description": {"widget": TextEditor()},
"slug": {"widget": PrepopulatedText(master='title')}
}
form_columns = ['title', 'slug', 'channel', 'related_channels', 'summary',
'description', 'published',
'unity_value',
'pre_requisites',
'duration',
'classes',
'variants',
'contents',
'show_on_channel', 'available_at', 'available_until',
'tags', 'values', 'template_type']
form_subdocuments = {
'classes': {
'form_subdocuments': {
None: {
'form_columns': (
'title', 'slug', 'description',
'start_date', 'end_date',
'weekdays', 'status', 'published'
)
}
}
},
'contents': {
'form_subdocuments': {
None: {
'form_columns': ('content', 'caption', 'purpose', 'order'),
'form_ajax_refs': {
'content': {
'fields': ['title', 'long_slug', 'summary']
}
}
}
}
},
}
class CourseSubscriptionAdmin(ModelAdmin):
roles_accepted = ('admin', 'editor')
column_list = [
'course', 'classroom', 'variant',
'student', 'subscriber',
'status', 'confirmed_date',
'unity_value',
'published'
]
form_columns = [
'course', 'classroom',
'student', 'subscriber',
'status', 'confirmed_date',
'unity_value',
'published', 'available_at', 'available_until',
'created_at',
'cart'
]
class SubscriberAdmin(ModelAdmin):
roles_accepted = ('admin', 'editor')
admin.register(Course, CourseAdmin, category=_("Classes"), name=_l("Course"))
admin.register(Subscriber,
SubscriberAdmin,
category=_("Classes"),
name=_l("Subscriber"))
admin.register(CourseSubscription,
CourseSubscriptionAdmin,
category=_("Classes"),
name=_l("Subscription"))