Skip to content

Commit 342f8a4

Browse files
committed
Add default ordering for RBAC models
1 parent 3636668 commit 342f8a4

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

ansible_base/rbac/migrations/0007_remote_permissions_cleanup.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,17 @@ class Migration(migrations.Migration):
7575
name='content_type',
7676
field=models.ForeignKey(help_text='The content type this permission will apply to.', on_delete=models.deletion.CASCADE, related_name='dab_permissions', to='dab_rbac.dabcontenttype', verbose_name='content type'),
7777
),
78+
# Add ordering on all models for consistent view pagination
79+
migrations.AlterModelOptions(
80+
name='dabcontenttype',
81+
options={'ordering': ['id']},
82+
),
83+
migrations.AlterModelOptions(
84+
name='roleevaluation',
85+
options={'ordering': ['id'], 'verbose_name_plural': 'role_object_permissions'},
86+
),
87+
migrations.AlterModelOptions(
88+
name='roleevaluationuuid',
89+
options={'ordering': ['id'], 'verbose_name_plural': 'role_object_permissions'},
90+
),
7891
]

ansible_base/rbac/models/content_type.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ class Meta:
241241
# that a single service can only continute a single model to the collective
242242
("service", "model"),
243243
]
244+
ordering = ['id']
244245

245246
def __str__(self) -> str:
246247
return self.app_labeled_name

ansible_base/rbac/models/role.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,7 @@ def has_obj_perm(cls, user, obj, codename) -> bool:
776776
class RoleEvaluation(RoleEvaluationFields):
777777
class Meta(RoleEvaluationMeta):
778778
constraints = [models.UniqueConstraint(name='one_entry_per_object_permission_and_role', fields=['object_id', 'content_type_id', 'codename', 'role'])]
779+
ordering = ['id']
779780

780781
role = models.ForeignKey(
781782
ObjectRole,
@@ -794,6 +795,7 @@ class Meta(RoleEvaluationMeta):
794795
constraints = [
795796
models.UniqueConstraint(name='one_entry_per_object_permission_and_role_uuid', fields=['object_id', 'content_type_id', 'codename', 'role'])
796797
]
798+
ordering = ['id']
797799

798800
role = models.ForeignKey(
799801
ObjectRole,

0 commit comments

Comments
 (0)