From fcfdb10ede8b1287a48e39bba591df3f2dd92a90 Mon Sep 17 00:00:00 2001 From: James Polley Date: Fri, 22 Dec 2017 18:43:02 +1100 Subject: [PATCH] Display Condition type in list views * Whether a Flag is disable-if-false or enable-if-true is a very important detail * But one that's easy to get wrong * And it's hard to spot problems without inspecting every single flag This change adds the Condition into the various admin list views, so that it's easier to scan them all for problems and look for inconsistencies. --- vendor/registrasion/registrasion/admin.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/vendor/registrasion/registrasion/admin.py b/vendor/registrasion/registrasion/admin.py index 3967b096..08204690 100644 --- a/vendor/registrasion/registrasion/admin.py +++ b/vendor/registrasion/registrasion/admin.py @@ -143,6 +143,11 @@ class VoucherAdmin(nested_admin.NestedAdmin): ''' List the effects of the voucher in the admin. ''' out = [] + try: + voucher_condition = obj.voucherflag.condition + except ObjectDoesNotExist: + voucher_condition = None + try: discount_effects = obj.voucherdiscount.effects() except ObjectDoesNotExist: @@ -155,6 +160,8 @@ class VoucherAdmin(nested_admin.NestedAdmin): if discount_effects: out.append("Discounts: " + str(list(discount_effects))) + if voucher_condition: + out.append("Condition: " + obj.voucherflag.get_condition_display()) if enabling_effects: out.append("Enables: " + str(list(enabling_effects))) @@ -181,7 +188,7 @@ class ProductFlagAdmin( fields = ("description", "enabling_products", "condition", "products", "categories"), - list_display = ("description", "enablers", "effects") + list_display = ("description", "condition", "enablers", "effects") # Enabling conditions @@ -194,7 +201,7 @@ class CategoryFlagAdmin( fields = ("description", "enabling_category", "condition", "products", "categories"), - list_display = ("description", "enabling_category", "effects") + list_display = ("description", "condition", "enabling_category", "effects") ordering = ("enabling_category",) @@ -215,13 +222,14 @@ class GroupMemberFlagAdmin(admin.ModelAdmin, EffectsDisplayMixin): fields = ("description", "group", "products", "categories") - list_display = ("description", "effects") + list_display = ("description", "condition", "effects") @admin.register(conditions.TimeOrStockLimitFlag) class TimeOrStockLimitFlagAdmin(admin.ModelAdmin, EffectsDisplayMixin): list_display = ( "description", + "condition", "start_time", "end_time", "limit",