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.
This commit is contained in:
James Polley 2017-12-22 18:43:02 +11:00
parent d19e34280a
commit fcfdb10ede

View file

@ -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",