bornhack-website/shop/admin.py

72 lines
1.5 KiB
Python
Raw Normal View History

from django.contrib import admin
from . import models
admin.site.register(models.EpayCallback)
admin.site.register(models.EpayPayment)
2016-05-29 10:54:02 +00:00
admin.site.register(models.CoinifyAPIInvoice)
admin.site.register(models.CoinifyAPICallback)
2016-05-29 10:54:02 +00:00
admin.site.register(models.Invoice)
2016-05-31 21:23:05 +00:00
@admin.register(models.ProductCategory)
class ProductCategoryAdmin(admin.ModelAdmin):
list_display = [
'name',
]
@admin.register(models.Product)
class ProductAdmin(admin.ModelAdmin):
list_display = [
'name',
'category',
'price',
'available_in',
]
class ProductInline(admin.TabularInline):
model = models.OrderProductRelation
class TicketInline(admin.TabularInline):
model = models.Ticket
exclude = ['qrcode_base64']
@admin.register(models.Order)
class OrderAdmin(admin.ModelAdmin):
2016-05-31 21:23:05 +00:00
change_form_template = 'admin/change_order_form.html'
list_display = [
2016-05-31 20:15:56 +00:00
'id',
'user',
'camp',
'payment_method',
'paid',
]
list_filter = [
'user',
'camp',
'payment_method',
'paid',
]
exclude = ['products']
inlines = [ProductInline, TicketInline]
actions = ['mark_order_as_paid']
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'
@admin.register(models.Ticket)
class TicketAdmin(admin.ModelAdmin):
2016-05-31 21:23:05 +00:00
pass