2017-08-17 15:51:24 +00:00
|
|
|
from django.contrib import admin
|
|
|
|
|
|
|
|
from .models import (
|
|
|
|
TicketType,
|
|
|
|
SponsorTicket,
|
|
|
|
DiscountTicket,
|
|
|
|
ShopTicket
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class BaseTicketAdmin(admin.ModelAdmin):
|
|
|
|
actions = ['generate_pdf']
|
|
|
|
exclude = ['qrcode_base64']
|
|
|
|
|
|
|
|
def generate_pdf(self, request, queryset):
|
|
|
|
for ticket in queryset.all():
|
|
|
|
ticket.generate_pdf()
|
|
|
|
generate_pdf.description = 'Generate PDF for the ticket'
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(TicketType)
|
|
|
|
class TicketTypeAdmin(admin.ModelAdmin):
|
2017-08-19 23:01:44 +00:00
|
|
|
list_display = [
|
|
|
|
'name',
|
|
|
|
'camp',
|
|
|
|
]
|
|
|
|
|
|
|
|
list_filter = [
|
|
|
|
'name',
|
|
|
|
'camp',
|
|
|
|
]
|
2017-08-17 15:51:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
@admin.register(SponsorTicket)
|
|
|
|
class SponsorTicketAdmin(BaseTicketAdmin):
|
2017-08-19 23:01:44 +00:00
|
|
|
list_display = [
|
|
|
|
'pk',
|
|
|
|
'ticket_type',
|
|
|
|
'sponsor',
|
|
|
|
'checked_in',
|
|
|
|
]
|
|
|
|
|
|
|
|
list_filter = [
|
2017-08-22 17:59:26 +00:00
|
|
|
'ticket_type__camp',
|
2017-08-22 17:45:01 +00:00
|
|
|
'checked_in',
|
2017-08-19 23:01:44 +00:00
|
|
|
'ticket_type',
|
|
|
|
'sponsor',
|
|
|
|
]
|
2017-08-17 15:51:24 +00:00
|
|
|
|
2017-08-22 17:36:24 +00:00
|
|
|
search_fields = ['name', 'email', 'sponsor__name']
|
|
|
|
|
2017-08-17 15:51:24 +00:00
|
|
|
|
|
|
|
@admin.register(DiscountTicket)
|
|
|
|
class DiscountTicketAdmin(BaseTicketAdmin):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(ShopTicket)
|
|
|
|
class ShopTicketAdmin(BaseTicketAdmin):
|
2017-08-22 17:59:26 +00:00
|
|
|
def user_email(self, obj):
|
|
|
|
return obj.order.user.email
|
|
|
|
|
2017-08-22 18:02:17 +00:00
|
|
|
def is_paid(self, obj):
|
|
|
|
return obj.order.paid
|
|
|
|
|
2017-08-19 23:01:44 +00:00
|
|
|
list_display = [
|
|
|
|
'pk',
|
2017-08-22 17:59:26 +00:00
|
|
|
'user_email',
|
2017-08-22 18:02:17 +00:00
|
|
|
'is_paid',
|
2017-08-19 23:01:44 +00:00
|
|
|
'ticket_type',
|
|
|
|
'order',
|
|
|
|
'product',
|
|
|
|
'checked_in',
|
|
|
|
]
|
|
|
|
|
|
|
|
list_filter = [
|
2017-08-22 17:48:18 +00:00
|
|
|
'ticket_type__camp',
|
2017-08-22 17:45:01 +00:00
|
|
|
'checked_in',
|
2017-08-19 23:01:44 +00:00
|
|
|
'ticket_type',
|
|
|
|
'order',
|
|
|
|
'product',
|
|
|
|
]
|
|
|
|
|
2017-08-22 18:09:26 +00:00
|
|
|
search_fields = ['uuid', 'order__id', 'order__user__email', 'name', 'email']
|