applied regex_replace automation to food and unit automations

updated automation documentation
This commit is contained in:
smilerz 2023-08-31 13:12:41 -05:00
parent 30c891abfc
commit 4120adc546
No known key found for this signature in database
GPG Key ID: 39444C7606D47126
2 changed files with 7 additions and 6 deletions

View File

@ -77,7 +77,7 @@ class AutomationEngine:
else:
if automation := Automation.objects.filter(space=self.request.space, type=Automation.UNIT_ALIAS, param_1__iexact=unit, disabled=False).order_by('order').first():
return automation.param_2
return unit
return self.apply_regex_replace_automation(unit, Automation.UNIT_REPLACE)
def apply_food_automation(self, food):
food = food.strip()
@ -102,7 +102,7 @@ class AutomationEngine:
else:
if automation := Automation.objects.filter(space=self.request.space, type=Automation.FOOD_ALIAS, param_1__iexact=food, disabled=False).order_by('order').first():
return automation.param_2
return self.apply_regex_replace_automation(food)
return self.apply_regex_replace_automation(food, Automation.FOOD_REPLACE)
def apply_never_unit_automation(self, tokens):
"""
@ -189,7 +189,6 @@ class AutomationEngine:
field_type are Automation.type that apply regex replacements
Automation.DESCRIPTION_REPLACE
Automation.INSTRUCTION_REPLACE
# TODO implement these
Automation.FOOD_REPLACE
Automation.UNIT_REPLACE
Automation.TITLE_REPLACE

View File

@ -50,10 +50,12 @@ In order to prevent denial of service attacks on the RegEx engine the number of
and the length of the inputs that are processed are limited. Those limits should never be reached
during normal usage.
## Instruction Replace
## Instructtion Replace, Title Replace, Food Replace & Unit Replace
This works just like the Description Replace automation but runs against all instruction texts
in all steps of a recipe during import.
These work just like the Description Replace automation.
Instruction, Food and Unit Replace will run against every iteration of the object in a recipe during import.
- Instruction Replace will run for the instructions in every step. It will also replace every occurrence, not just the first.
- Food & Unit Replace will run for every food and unit in every ingredient in every step.
Also instead of just replacing a single occurrence of the matched pattern it will replace all.