mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
Fixes #14816: Ensure default contact assignment ordering is consistent
This commit is contained in:
parent
621c3ccfa4
commit
5de2dea8a6
@ -83,6 +83,6 @@ class ContactViewSet(NetBoxModelViewSet):
|
||||
|
||||
|
||||
class ContactAssignmentViewSet(NetBoxModelViewSet):
|
||||
queryset = ContactAssignment.objects.prefetch_related('object', 'contact', 'role')
|
||||
queryset = ContactAssignment.objects.prefetch_related('content_type', 'object', 'contact', 'role', 'tags')
|
||||
serializer_class = serializers.ContactAssignmentSerializer
|
||||
filterset_class = filtersets.ContactAssignmentFilterSet
|
||||
|
17
netbox/tenancy/migrations/0014_contactassignment_ordering.py
Normal file
17
netbox/tenancy/migrations/0014_contactassignment_ordering.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Generated by Django 4.2.8 on 2024-01-17 15:27
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('tenancy', '0013_gfk_indexes'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='contactassignment',
|
||||
options={'ordering': ('contact', 'priority', 'role', 'pk')},
|
||||
),
|
||||
]
|
@ -140,7 +140,7 @@ class ContactAssignment(CustomFieldsMixin, ExportTemplatesMixin, TagsMixin, Chan
|
||||
clone_fields = ('content_type', 'object_id', 'role', 'priority')
|
||||
|
||||
class Meta:
|
||||
ordering = ('priority', 'contact')
|
||||
ordering = ('contact', 'priority', 'role', 'pk')
|
||||
indexes = (
|
||||
models.Index(fields=('content_type', 'object_id')),
|
||||
)
|
||||
|
@ -25,7 +25,7 @@ class ObjectContactsView(generic.ObjectChildrenView):
|
||||
return ContactAssignment.objects.restrict(request.user, 'view').filter(
|
||||
content_type=ContentType.objects.get_for_model(parent),
|
||||
object_id=parent.pk
|
||||
)
|
||||
).order_by('priority', 'contact', 'role')
|
||||
|
||||
def get_table(self, *args, **kwargs):
|
||||
table = super().get_table(*args, **kwargs)
|
||||
|
Loading…
Reference in New Issue
Block a user