Refactoring
This commit is contained in:
parent
5f13e91267
commit
4f2af09464
@ -1632,14 +1632,13 @@ class CategorisationRule(models.Model):
|
||||
|
||||
# all rules are applied, starting from the first to the last
|
||||
def apply_rules(event):
|
||||
rules = CategorisationRule.objects.all().order_by("weight", "pk")
|
||||
|
||||
for rule in rules:
|
||||
if rule.match(event):
|
||||
event.category = rule.category
|
||||
return 1
|
||||
|
||||
return 0
|
||||
c = CategorisationRule.get_category_from_rules(event)
|
||||
|
||||
if c is None:
|
||||
return 0
|
||||
else:
|
||||
event.category = c
|
||||
return 1
|
||||
|
||||
def get_category_from_rules(event):
|
||||
rules = CategorisationRule.objects.all().order_by("weight", "pk")
|
||||
|
@ -1749,14 +1749,14 @@ def apply_categorisation_rules(request):
|
||||
messages.success(
|
||||
request,
|
||||
_(
|
||||
"The rules were successfully applied and 1 event was categorised."
|
||||
"The rules were successfully applied and 1 event with default category was categorised."
|
||||
),
|
||||
)
|
||||
else:
|
||||
messages.success(
|
||||
request,
|
||||
_(
|
||||
"The rules were successfully applied and {} events were categorised."
|
||||
"The rules were successfully applied and {} events with default category were categorised."
|
||||
).format(nb),
|
||||
)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user