-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathadmin.py
151 lines (118 loc) · 5.06 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
from django.contrib import admin
from .models import Events, Gallery
from .models import TeamParticipant, Team, Payer, SoloParicipants, PayUTxn
from utility import export_as_csv
# Register your models here.
# admin.site.register(Events)
# admin.site.register(Gallery)
@admin.register(Events)
class EventsAdmin(admin.ModelAdmin):
list_display = ('id', 'name', 'organizer', 'start_time', 'tags')
search_fields = ('name', 'organizer', 'venue', 'tags')
list_filter = ('tags', 'start_time', 'prize', 'registration_fee',
'max_team_size', 'registration_deadline')
list_per_page = 20
readonly_fields = ['id']
fieldsets = (
('Basic Information', {
'fields': (
('id', 'name'),
('organizer', 'venue'),
('start_time', 'end_time'),
('tags', 'prize'),
('registration_fee', 'registration_deadline'),
('description'),
('max_team_size', 'min_team_size'),
('poster', 'video'),
('is_active', 'is_online'),
('registration_link'),
('order'),
('payment_link', 'payment_key'),
),
}),
)
empty_value_display = '-empty-'
actions = [export_as_csv]
@admin.register(Gallery)
class GalleryAdmin(admin.ModelAdmin):
list_display = ('name', 'file', 'tags', 'tags')
search_fields = ('name',)
list_filter = ('tags', 'type')
list_per_page = 20
empty_value_display = '-empty-'
# @admin.register(add_merch)
# class add_merchAdmin(admin.ModelAdmin):
# list_display = ('title', 'description', 'prices', 'image')
# search_fields = ('title',)
# empty_value_display = '-empty-'
# actions = [export_as_csv]
# @admin.register(order_merch)
# class order_merchAdmin(admin.ModelAdmin):
# def merch(self, obj):
# return obj.merch_title.title
# list_display = ('anwesha_id', 'merch_title', 'address','size','quantity','payment_status')
# search_fields = ['name','email','phone_no','merch_title__title']
# empty_value_display = '-empty-'
# actions = [export_as_csv]
@admin.register(TeamParticipant)
class ParticipantAdmin(admin.ModelAdmin):
@admin.action(description='Lock Selected User')
def lock_user(self, request, queryset):
queryset.update(is_locked=True)
self.message_user(request, "Selected User Locked")
def fullname(self, obj):
return obj.anwesha_id.full_name
def eventname(self, obj):
return obj.event_id.name
list_display = ('anwesha_id', 'fullname', 'event_id', 'eventname', 'team_id','has_entered')
search_fields = ('anwesha_id__anwesha_id', 'anwesha_id__email_id',
'anwesha_id__full_name', 'event_id__id', 'event_id__name',
'team_id__team_id', 'team_id__team_name')
actions = [lock_user, export_as_csv]
@admin.register(Team)
class TeamAdmin(admin.ModelAdmin):
def fullname(self, obj):
return obj.leader_id.full_name
def eventname(self, obj):
return obj.event_id.name
@admin.action(description='Lock Selected User')
def lock_user(self, request, queryset):
queryset.update(is_locked=True)
self.message_user(request, "Selected User Locked")
list_display = ('team_id', 'event_id','eventname', 'leader_id', 'fullname', 'team_name')
search_fields = ('team_id', 'event_id__id', 'event_id__name',
'leader_id__anwesha_id', 'leader_id__email_id', 'team_name')
actions = [lock_user, export_as_csv]
@admin.register(Payer)
class PayerAdmin(admin.ModelAdmin):
@admin.action(description='Lock Selected User')
def lock_user(self, request, queryset):
queryset.update(is_locked=True)
self.message_user(request, "Selected User Locked")
list_display = ('team_id', 'payer_id', 'payment_status',)
search_fields = ('team_id', 'payer_id', 'reference_id')
list_filter = ('payment_status',)
actions = [lock_user, export_as_csv]
@admin.register(SoloParicipants)
class SoloAdmin(admin.ModelAdmin):
@admin.action(description='Lock Selected User')
def lock_user(self, request, queryset):
queryset.update(is_locked=True)
self.message_user(request, "Selected User Locked")
def fullname(self, obj):
return obj.anwesha_id.full_name
def eventname(self, obj):
return obj.event_id.name
list_display = ('anwesha_id','fullname', 'event_id','eventname', 'payment_done','has_entered')
search_fields = ('anwesha_id__anwesha_id', 'anwesha_id__email_id',
'anwesha_id__full_name', 'event_id__id', 'event_id__name')
list_filter = (('payment_done', admin.BooleanFieldListFilter),)
actions = [lock_user, export_as_csv]
@admin.register(PayUTxn)
class PayUTxnAdmin(admin.ModelAdmin):
list_display = ('txnid', 'amount', 'firstname',
'email', 'productinfo', 'status')
search_fields = ('txnid', 'firstname', 'email', 'phone')
list_filter = ('status', 'productinfo')
empty_value_display = '-empty-'
actions = [export_as_csv]