From 4b8051cca23240630352e163edb5bd38f7e1d472 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Fri, 27 Dec 2024 02:10:09 -0300 Subject: [PATCH] refactor(rules): rename TransactionRuleAction related_name from "action" to "transaction_actions" --- .../0005_alter_transactionruleaction_rule.py | 19 +++++++++++++++++++ app/apps/rules/models.py | 2 +- app/apps/rules/tasks.py | 2 +- .../fragments/transaction_rule/view.html | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 app/apps/rules/migrations/0005_alter_transactionruleaction_rule.py diff --git a/app/apps/rules/migrations/0005_alter_transactionruleaction_rule.py b/app/apps/rules/migrations/0005_alter_transactionruleaction_rule.py new file mode 100644 index 0000000..e390932 --- /dev/null +++ b/app/apps/rules/migrations/0005_alter_transactionruleaction_rule.py @@ -0,0 +1,19 @@ +# Generated by Django 5.1.3 on 2024-12-27 05:09 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('rules', '0004_alter_transactionruleaction_field'), + ] + + operations = [ + migrations.AlterField( + model_name='transactionruleaction', + name='rule', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='transaction_actions', to='rules.transactionrule', verbose_name='Rule'), + ), + ] diff --git a/app/apps/rules/models.py b/app/apps/rules/models.py index d8fd6c6..a33cc13 100644 --- a/app/apps/rules/models.py +++ b/app/apps/rules/models.py @@ -31,7 +31,7 @@ class TransactionRuleAction(models.Model): rule = models.ForeignKey( TransactionRule, on_delete=models.CASCADE, - related_name="actions", + related_name="transaction_actions", verbose_name=_("Rule"), ) field = models.CharField( diff --git a/app/apps/rules/tasks.py b/app/apps/rules/tasks.py index d0f8381..f67f72e 100644 --- a/app/apps/rules/tasks.py +++ b/app/apps/rules/tasks.py @@ -68,7 +68,7 @@ def check_for_transaction_rules( for rule in rules: if simple.eval(rule.trigger): - for action in rule.actions.all(): + for action in rule.transaction_actions.all(): if action.field in [ TransactionRuleAction.Field.type, TransactionRuleAction.Field.is_paid, diff --git a/app/templates/rules/fragments/transaction_rule/view.html b/app/templates/rules/fragments/transaction_rule/view.html index 2ba4d95..eafc7c1 100644 --- a/app/templates/rules/fragments/transaction_rule/view.html +++ b/app/templates/rules/fragments/transaction_rule/view.html @@ -29,7 +29,7 @@
{% translate 'Then...' %}
- {% for action in transaction_rule.actions.all %} + {% for action in transaction_rule.transaction_actions.all %}