-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(model): allow configuring display order of EligibilityVerifiers
use `django-admin-sortable2` to handle updating / editing.
- Loading branch information
1 parent
33d11d5
commit 09be83e
Showing
5 changed files
with
42 additions
and
1 deletion.
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
30 changes: 30 additions & 0 deletions
30
benefits/core/migrations/0004_alter_eligibilityverifier_display_order.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,30 @@ | ||
# Generated by Django 5.0.3 on 2024-03-19 20:22 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("core", "0003_eligibilitytype_expiration"), | ||
] | ||
|
||
# see https://django-admin-sortable2.readthedocs.io/en/latest/usage.html#initial-data | ||
def set_initial_display_order(apps, schema_editor): | ||
EligibilityVerifier = apps.get_model("core", "EligibilityVerifier") | ||
for order, item in enumerate(EligibilityVerifier.objects.all(), 1): | ||
item.display_order = order | ||
item.save(update_fields=["display_order"]) | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name="eligibilityverifier", | ||
options={"ordering": ["display_order"]}, | ||
), | ||
migrations.AddField( | ||
model_name="eligibilityverifier", | ||
name="display_order", | ||
field=models.PositiveSmallIntegerField(default=0), | ||
), | ||
migrations.RunPython(set_initial_display_order, reverse_code=migrations.RunPython.noop), | ||
] |
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