Skip to content

Commit

Permalink
rules: simplify toggle availability
Browse files Browse the repository at this point in the history
Do it on a per rule basis as this is not a frequent operation.
  • Loading branch information
regit committed Mar 12, 2018
1 parent 331eaaf commit 3627cce
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions rules/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1454,13 +1454,9 @@ def test(self, ruleset):
return False

def toggle_availability(self):
toggle_rules = self.get_dependant_rules(ruleset)
self.category.source.needs_test()
if not toggle_rules:
toggle_rules |= {self}
for rule in toggle_rules:
rule.state = not rule.state
rule.save()
self.state = not self.state
self.save()

def apply_transformation(self, content, key=Transformation.ACTION, value=None):

Expand Down

0 comments on commit 3627cce

Please sign in to comment.