You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

admin.py 1.0KB

123456789101112131415161718192021222324252627282930
  1. from django.contrib import admin
  2. from oscar.core.loading import get_model
  3. Voucher = get_model('voucher', 'Voucher')
  4. VoucherApplication = get_model('voucher', 'VoucherApplication')
  5. class VoucherAdmin(admin.ModelAdmin):
  6. list_display = ('name', 'code', 'usage', 'num_basket_additions',
  7. 'num_orders', 'total_discount')
  8. readonly_fields = ('num_basket_additions', 'num_orders', 'total_discount')
  9. fieldsets = (
  10. (None, {
  11. 'fields': ('name', 'code', 'usage', 'start_datetime',
  12. 'end_datetime')}),
  13. ('Benefit', {
  14. 'fields': ('offers',)}),
  15. ('Usage', {
  16. 'fields': ('num_basket_additions', 'num_orders',
  17. 'total_discount')}),
  18. )
  19. class VoucherApplicationAdmin(admin.ModelAdmin):
  20. list_display = ('voucher', 'user', 'order', 'date_created')
  21. readonly_fields = ('voucher', 'user', 'order')
  22. admin.site.register(Voucher, VoucherAdmin)
  23. admin.site.register(VoucherApplication, VoucherApplicationAdmin)