2018-08-31 12:46:35 +00:00
|
|
|
from django.contrib import admin
|
2018-11-27 08:07:12 +00:00
|
|
|
from simple_history.admin import SimpleHistoryAdmin
|
2018-08-31 12:46:35 +00:00
|
|
|
|
2019-05-03 19:09:32 +00:00
|
|
|
from .models import Reload, Refund, Product, Keg, ConsumptionHistory, KegHistory, Consumption, Menu, MenuHistory, Category
|
2018-10-05 22:03:02 +00:00
|
|
|
|
2019-02-27 07:59:41 +00:00
|
|
|
class ConsumptionAdmin(SimpleHistoryAdmin):
|
2019-02-28 12:18:41 +00:00
|
|
|
"""
|
|
|
|
The admin class for :class:`Consumptions <gestion.models.Consumption>`.
|
|
|
|
"""
|
2019-02-27 07:59:41 +00:00
|
|
|
list_display = ('customer', 'product', 'quantity')
|
|
|
|
ordering = ('-quantity', )
|
|
|
|
search_fields = ('customer', 'product')
|
|
|
|
|
|
|
|
class ConsumptionHistoryAdmin(SimpleHistoryAdmin):
|
2019-02-28 12:18:41 +00:00
|
|
|
"""
|
|
|
|
The admin class for :class:`Consumption Histories <gestion.models.ConsumptionHistory>`.
|
|
|
|
"""
|
2019-02-27 07:59:41 +00:00
|
|
|
list_display = ('customer', 'product', 'quantity', 'paymentMethod', 'date', 'amount')
|
|
|
|
ordering = ('-date', )
|
|
|
|
search_fields = ('customer', 'product')
|
|
|
|
list_filter = ('paymentMethod',)
|
|
|
|
|
|
|
|
class KegAdmin(SimpleHistoryAdmin):
|
2019-02-28 12:18:41 +00:00
|
|
|
"""
|
|
|
|
The admin class for :class:`Kegs <gestion.models.Keg>`.
|
|
|
|
"""
|
2019-02-27 07:59:41 +00:00
|
|
|
list_display = ('name', 'stockHold', 'capacity', 'is_active')
|
|
|
|
ordering = ('name', )
|
|
|
|
search_fields = ('name',)
|
|
|
|
list_filter = ('capacity', 'is_active')
|
|
|
|
|
|
|
|
class KegHistoryAdmin(SimpleHistoryAdmin):
|
2019-02-28 12:18:41 +00:00
|
|
|
"""
|
|
|
|
The admin class for :class:`Keg Histories <gestion.models.KegHistory>`.
|
|
|
|
"""
|
2019-02-27 07:59:41 +00:00
|
|
|
list_display = ('keg', 'openingDate', 'closingDate', 'isCurrentKegHistory', 'quantitySold')
|
|
|
|
ordering = ('-openingDate', 'quantitySold')
|
|
|
|
search_fields = ('keg',)
|
|
|
|
list_filter = ('isCurrentKegHistory', 'keg')
|
|
|
|
|
|
|
|
class MenuHistoryAdmin(SimpleHistoryAdmin):
|
2019-02-28 12:18:41 +00:00
|
|
|
"""
|
|
|
|
The admin class for :class:`Menu Histories <gestion.models.MenuHistory>`.
|
|
|
|
"""
|
2019-02-27 07:59:41 +00:00
|
|
|
list_display = ('customer', 'menu', 'paymentMethod', 'date', 'quantity', 'amount')
|
|
|
|
ordering = ('-date',)
|
|
|
|
search_fields = ('customer', 'menu')
|
|
|
|
|
|
|
|
class MenuAdmin(SimpleHistoryAdmin):
|
2019-02-28 12:18:41 +00:00
|
|
|
"""
|
|
|
|
The admin class for :class:`Menu <gestion.models.Menu>`.
|
|
|
|
"""
|
2019-02-27 07:59:41 +00:00
|
|
|
list_display = ('name', 'amount', 'is_active')
|
|
|
|
ordering = ('name', 'amount')
|
|
|
|
search_fields = ('name',)
|
|
|
|
list_filter = ('is_active', )
|
|
|
|
|
|
|
|
class ProductAdmin(SimpleHistoryAdmin):
|
2019-02-28 12:18:41 +00:00
|
|
|
"""
|
|
|
|
The admin class for :class:`Products <gestion.models.Product>`.
|
|
|
|
"""
|
2019-02-27 07:59:41 +00:00
|
|
|
list_display = ('name', 'amount', 'is_active', 'category', 'adherentRequired', 'stockHold', 'stockBar', 'volume', 'deg')
|
|
|
|
ordering = ('name', 'amount', 'stockHold', 'stockBar', 'deg')
|
|
|
|
search_fields = ('name',)
|
|
|
|
list_filter = ('is_active', 'adherentRequired', 'category')
|
|
|
|
|
|
|
|
class ReloadAdmin(SimpleHistoryAdmin):
|
2019-02-28 12:18:41 +00:00
|
|
|
"""
|
|
|
|
The admin class for :class:`Reloads <gestion.models.Reload>`.
|
|
|
|
"""
|
2019-02-27 07:59:41 +00:00
|
|
|
list_display = ('customer', 'amount', 'date', 'PaymentMethod')
|
|
|
|
ordering = ('-date', 'amount', 'customer')
|
|
|
|
search_fields = ('customer',)
|
|
|
|
list_filter = ('PaymentMethod', )
|
|
|
|
|
|
|
|
class RefundAdmin(SimpleHistoryAdmin):
|
2019-02-28 12:18:41 +00:00
|
|
|
"""
|
|
|
|
The admin class for :class:`Refunds <gestion.models.Refund>`.
|
|
|
|
"""
|
2019-02-27 07:59:41 +00:00
|
|
|
list_display = ('customer', 'amount', 'date')
|
|
|
|
ordering = ('-date', 'amount', 'customer')
|
|
|
|
search_fields = ('customer',)
|
|
|
|
|
2019-05-03 19:09:32 +00:00
|
|
|
class CategoryAdmin(SimpleHistoryAdmin):
|
|
|
|
"""
|
|
|
|
The admin class for Category
|
|
|
|
"""
|
|
|
|
ordering = ("order",)
|
|
|
|
|
2019-02-27 07:59:41 +00:00
|
|
|
admin.site.register(Reload, ReloadAdmin)
|
|
|
|
admin.site.register(Refund, RefundAdmin)
|
|
|
|
admin.site.register(Product, ProductAdmin)
|
|
|
|
admin.site.register(Keg, KegAdmin)
|
|
|
|
admin.site.register(ConsumptionHistory, ConsumptionHistoryAdmin)
|
|
|
|
admin.site.register(KegHistory, KegHistoryAdmin)
|
|
|
|
admin.site.register(Consumption, ConsumptionAdmin)
|
|
|
|
admin.site.register(Menu, MenuAdmin)
|
2019-05-03 19:09:32 +00:00
|
|
|
admin.site.register(MenuHistory, MenuHistoryAdmin)
|
|
|
|
admin.site.register(Category, CategoryAdmin)
|