-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automation Rules: simplify ordering (#10896)
I'm trying to re-use this for redirects, and found a couple of things that we can improve. - New items would be inserted first instead of at the end, if a user is adding a new item, they may want to have it priority over existing ones. Inserting the item at the end was mostly done because it was "easier" to implement. - Instead of explicitly using the manager to add a new rule, just override the save() method. This allows us to: - Insert a new rule with any priority - Change the priority of a rule by just saving it with the new priority. With this, we no longer need to override forms, serializers, etc, saving the model will take care of putting the rule in the right place.
- Loading branch information
Showing
8 changed files
with
182 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
readthedocs/builds/migrations/0055_alter_versionautomationrule_priority.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Generated by Django 4.2.5 on 2023-11-08 22:18 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("builds", "0054_add_builds_index_for_addons"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="versionautomationrule", | ||
name="priority", | ||
field=models.IntegerField( | ||
default=0, | ||
help_text="A lower number (0) means a higher priority", | ||
verbose_name="Rule priority", | ||
), | ||
), | ||
] |
21 changes: 21 additions & 0 deletions
21
readthedocs/builds/migrations/0056_alter_versionautomationrule_priority.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Generated by Django 4.2.5 on 2023-11-22 16:50 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("builds", "0055_alter_versionautomationrule_priority"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="versionautomationrule", | ||
name="priority", | ||
field=models.PositiveIntegerField( | ||
default=0, | ||
help_text="A lower number (0) means a higher priority", | ||
verbose_name="Rule priority", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.