added model admin for coupons
This commit is contained in:
@@ -1,3 +1,40 @@
|
||||
from django.contrib import admin
|
||||
from .models import Coupon
|
||||
|
||||
# Register your models here.
|
||||
|
||||
class CouponAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
"id",
|
||||
"title",
|
||||
"coupon_id",
|
||||
"coupon_code",
|
||||
"discount_amount",
|
||||
"discount_percentage",
|
||||
"valid_from",
|
||||
"valid_to",
|
||||
"max_redeems",
|
||||
"no_of_redeems",
|
||||
"is_active",
|
||||
)
|
||||
search_fields = ("title", "coupon_code")
|
||||
list_filter = ("valid_from", "valid_to", "max_redeems")
|
||||
readonly_fields = ("no_of_redeems",)
|
||||
|
||||
fieldsets = (
|
||||
(
|
||||
None,
|
||||
{"fields": ("title", "coupon_code", "coupon_id", "description", "image")},
|
||||
),
|
||||
(
|
||||
"Discount Information",
|
||||
{"fields": ("discount_amount", "discount_percentage")},
|
||||
),
|
||||
("Validity", {"fields": ("valid_from", "valid_to")}),
|
||||
("Redemption", {"fields": ("max_redeems", "no_of_redeems")}),
|
||||
)
|
||||
|
||||
def is_active(self, obj):
|
||||
return obj.is_valid()
|
||||
|
||||
|
||||
admin.site.register(Coupon, CouponAdmin)
|
||||
|
||||
Reference in New Issue
Block a user