2016-06-19 06:43:56 +00:00
|
|
|
from django.contrib import admin
|
2016-05-10 20:20:01 +00:00
|
|
|
|
2016-05-25 17:13:45 +00:00
|
|
|
from . import models
|
2016-05-10 20:20:01 +00:00
|
|
|
|
2016-05-25 17:13:45 +00:00
|
|
|
admin.site.register(models.EpayCallback)
|
|
|
|
admin.site.register(models.EpayPayment)
|
2016-05-29 10:54:02 +00:00
|
|
|
admin.site.register(models.CoinifyAPIInvoice)
|
2016-05-29 17:33:26 +00:00
|
|
|
admin.site.register(models.CoinifyAPICallback)
|
2016-05-29 10:54:02 +00:00
|
|
|
admin.site.register(models.Invoice)
|
2016-06-18 18:51:53 +00:00
|
|
|
admin.site.register(models.CreditNote)
|
2016-07-12 20:42:30 +00:00
|
|
|
admin.site.register(models.CustomOrder)
|
2016-05-31 21:23:05 +00:00
|
|
|
|
2016-08-27 08:17:43 +00:00
|
|
|
|
2016-05-25 17:13:45 +00:00
|
|
|
@admin.register(models.ProductCategory)
|
2016-05-10 20:20:01 +00:00
|
|
|
class ProductCategoryAdmin(admin.ModelAdmin):
|
|
|
|
list_display = [
|
|
|
|
'name',
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2016-05-25 17:13:45 +00:00
|
|
|
@admin.register(models.Product)
|
2016-05-10 20:20:01 +00:00
|
|
|
class ProductAdmin(admin.ModelAdmin):
|
|
|
|
list_display = [
|
|
|
|
'name',
|
|
|
|
'category',
|
|
|
|
'price',
|
|
|
|
'available_in',
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
class ProductInline(admin.TabularInline):
|
2016-05-25 17:13:45 +00:00
|
|
|
model = models.OrderProductRelation
|
2016-05-10 20:20:01 +00:00
|
|
|
|
|
|
|
|
2016-05-25 18:05:31 +00:00
|
|
|
class TicketInline(admin.TabularInline):
|
|
|
|
model = models.Ticket
|
|
|
|
exclude = ['qrcode_base64']
|
|
|
|
|
|
|
|
|
2016-05-25 17:13:45 +00:00
|
|
|
@admin.register(models.Order)
|
2016-05-10 20:20:01 +00:00
|
|
|
class OrderAdmin(admin.ModelAdmin):
|
2016-05-31 21:23:05 +00:00
|
|
|
change_form_template = 'admin/change_order_form.html'
|
2016-07-05 19:43:09 +00:00
|
|
|
readonly_fields = ('paid',)
|
2016-06-04 07:46:10 +00:00
|
|
|
|
|
|
|
def get_email(self, obj):
|
|
|
|
return obj.user.email
|
|
|
|
|
2016-05-10 20:20:01 +00:00
|
|
|
list_display = [
|
2016-05-31 20:15:56 +00:00
|
|
|
'id',
|
2016-05-10 20:20:01 +00:00
|
|
|
'user',
|
2016-06-04 07:46:10 +00:00
|
|
|
'get_email',
|
2016-06-04 07:37:54 +00:00
|
|
|
'total',
|
2016-05-10 20:20:01 +00:00
|
|
|
'payment_method',
|
2016-06-04 07:37:54 +00:00
|
|
|
'open',
|
2016-05-10 20:20:01 +00:00
|
|
|
'paid',
|
2016-06-01 09:10:06 +00:00
|
|
|
'cancelled',
|
2016-06-18 21:42:58 +00:00
|
|
|
'refunded',
|
2016-05-10 20:20:01 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
list_filter = [
|
|
|
|
'camp',
|
|
|
|
'payment_method',
|
2016-06-04 07:37:54 +00:00
|
|
|
'open',
|
2016-05-10 20:20:01 +00:00
|
|
|
'paid',
|
2016-06-04 07:37:54 +00:00
|
|
|
'cancelled',
|
2016-06-18 21:42:58 +00:00
|
|
|
'refunded',
|
2016-06-18 18:51:53 +00:00
|
|
|
'user',
|
2016-05-10 20:20:01 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
exclude = ['products']
|
|
|
|
|
2016-05-25 18:05:31 +00:00
|
|
|
inlines = [ProductInline, TicketInline]
|
|
|
|
|
2016-06-18 21:42:58 +00:00
|
|
|
actions = ['mark_order_as_paid', 'mark_order_as_refunded']
|
2016-05-25 18:05:31 +00:00
|
|
|
|
|
|
|
def mark_order_as_paid(self, request, queryset):
|
|
|
|
for order in queryset.filter(paid=False):
|
|
|
|
order.mark_as_paid()
|
|
|
|
mark_order_as_paid.description = 'Mark order(s) as paid'
|
2016-05-10 20:20:01 +00:00
|
|
|
|
2016-06-18 21:42:58 +00:00
|
|
|
def mark_order_as_refunded(self, request, queryset):
|
|
|
|
for order in queryset.filter(refunded=False):
|
2016-06-19 06:49:30 +00:00
|
|
|
order.mark_as_refunded(request)
|
2016-06-18 21:42:58 +00:00
|
|
|
mark_order_as_refunded.description = 'Mark order(s) as refunded'
|
2016-05-25 17:13:45 +00:00
|
|
|
|
2016-08-27 08:17:43 +00:00
|
|
|
|
2016-08-27 08:29:26 +00:00
|
|
|
def get_user_email(obj):
|
|
|
|
return obj.order.user.email
|
|
|
|
|
|
|
|
|
2016-08-27 08:17:43 +00:00
|
|
|
@admin.register(models.Ticket)
|
|
|
|
class TicketModelAdmin(admin.ModelAdmin):
|
2016-08-27 08:29:26 +00:00
|
|
|
list_display = [
|
|
|
|
'order',
|
|
|
|
'product',
|
|
|
|
'name',
|
|
|
|
'email',
|
|
|
|
get_user_email,
|
|
|
|
'get_token',
|
|
|
|
'checked_in'
|
|
|
|
]
|
|
|
|
|
2016-08-27 10:29:51 +00:00
|
|
|
list_filter = ['product', 'checked_in']
|
2016-08-27 08:40:57 +00:00
|
|
|
|
2016-08-27 08:17:43 +00:00
|
|
|
|
|
|
|
actions = ['mark_as_arrived']
|
|
|
|
|
|
|
|
def mark_as_arrived(self, request, queryset):
|
|
|
|
queryset.update(checked_in=True)
|
|
|
|
|
|
|
|
|