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 986B

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