Simplifies flag and discount filter functions

This commit is contained in:
Christopher Neugebauer 2016-05-01 19:12:40 +10:00
parent b9b50c6846
commit abe8c12b05
2 changed files with 2 additions and 6 deletions

View file

@ -127,12 +127,10 @@ class DiscountController(object):
"discount",
)
valid_discounts = conditions.DiscountBase.objects.all()
all_subsets = []
for discounttype in discounttypes:
discounts = discounttype.objects.filter(id__in=valid_discounts)
discounts = discounttype.objects.all()
ctrl = ConditionController.for_type(discounttype)
discounts = ctrl.pre_filter(discounts, user)
all_subsets.append(discounts)

View file

@ -173,12 +173,10 @@ class FlagController(object):
types = list(ConditionController._controllers())
flagtypes = [i for i in types if issubclass(i, conditions.FlagBase)]
all_flags = conditions.FlagBase.objects.all()
all_subsets = []
for flagtype in flagtypes:
flags = flagtype.objects.filter(id__in=all_flags)
flags = flagtype.objects.all()
ctrl = ConditionController.for_type(flagtype)
flags = ctrl.pre_filter(flags, user)
all_subsets.append(flags)