mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -06:00
Closes #11584: Add a list view for contact assignments
This commit is contained in:
parent
6e264562ee
commit
157bf89e89
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
### Enhancements
|
### Enhancements
|
||||||
|
|
||||||
|
* [#11584](https://github.com/netbox-community/netbox/issues/11584) - Add a list view for contact assignments
|
||||||
* [#11254](https://github.com/netbox-community/netbox/issues/11254) - Introduce the `X-Request-ID` HTTP header to annotate the unique ID of each request for change logging
|
* [#11254](https://github.com/netbox-community/netbox/issues/11254) - Introduce the `X-Request-ID` HTTP header to annotate the unique ID of each request for change logging
|
||||||
* [#11440](https://github.com/netbox-community/netbox/issues/11440) - Add an `enabled` field for device type interfaces
|
* [#11440](https://github.com/netbox-community/netbox/issues/11440) - Add an `enabled` field for device type interfaces
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ ORGANIZATION_MENU = Menu(
|
|||||||
get_model_item('tenancy', 'contact', _('Contacts')),
|
get_model_item('tenancy', 'contact', _('Contacts')),
|
||||||
get_model_item('tenancy', 'contactgroup', _('Contact Groups')),
|
get_model_item('tenancy', 'contactgroup', _('Contact Groups')),
|
||||||
get_model_item('tenancy', 'contactrole', _('Contact Roles')),
|
get_model_item('tenancy', 'contactrole', _('Contact Roles')),
|
||||||
|
get_model_item('tenancy', 'contactassignment', _('Contact Assignments'), actions=[]),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
|
from extras.utils import FeatureQuery
|
||||||
from netbox.forms import NetBoxModelFilterSetForm
|
from netbox.forms import NetBoxModelFilterSetForm
|
||||||
|
from tenancy.choices import *
|
||||||
from tenancy.models import *
|
from tenancy.models import *
|
||||||
from tenancy.forms import ContactModelFilterForm
|
from tenancy.forms import ContactModelFilterForm
|
||||||
from utilities.forms import DynamicModelMultipleChoiceField, TagFilterField
|
from utilities.forms.fields import (
|
||||||
|
ContentTypeMultipleChoiceField, DynamicModelMultipleChoiceField, MultipleChoiceField, TagFilterField,
|
||||||
|
)
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
|
'ContactAssignmentFilterForm',
|
||||||
'ContactFilterForm',
|
'ContactFilterForm',
|
||||||
'ContactGroupFilterForm',
|
'ContactGroupFilterForm',
|
||||||
'ContactRoleFilterForm',
|
'ContactRoleFilterForm',
|
||||||
@ -71,3 +77,36 @@ class ContactFilterForm(NetBoxModelFilterSetForm):
|
|||||||
label=_('Group')
|
label=_('Group')
|
||||||
)
|
)
|
||||||
tag = TagFilterField(model)
|
tag = TagFilterField(model)
|
||||||
|
|
||||||
|
|
||||||
|
class ContactAssignmentFilterForm(NetBoxModelFilterSetForm):
|
||||||
|
model = ContactAssignment
|
||||||
|
fieldsets = (
|
||||||
|
(None, ('q', 'filter_id')),
|
||||||
|
('Assignment', ('content_type_id', 'group_id', 'contact_id', 'role_id', 'priority')),
|
||||||
|
)
|
||||||
|
content_type_id = ContentTypeMultipleChoiceField(
|
||||||
|
queryset=ContentType.objects.all(),
|
||||||
|
limit_choices_to=FeatureQuery('custom_fields'),
|
||||||
|
required=False,
|
||||||
|
label=_('Object type')
|
||||||
|
)
|
||||||
|
group_id = DynamicModelMultipleChoiceField(
|
||||||
|
queryset=ContactGroup.objects.all(),
|
||||||
|
required=False,
|
||||||
|
label=_('Group')
|
||||||
|
)
|
||||||
|
contact_id = DynamicModelMultipleChoiceField(
|
||||||
|
queryset=Contact.objects.all(),
|
||||||
|
required=False,
|
||||||
|
label=_('Contact')
|
||||||
|
)
|
||||||
|
role_id = DynamicModelMultipleChoiceField(
|
||||||
|
queryset=ContactRole.objects.all(),
|
||||||
|
required=False,
|
||||||
|
label=_('Role')
|
||||||
|
)
|
||||||
|
priority = MultipleChoiceField(
|
||||||
|
choices=ContactPriorityChoices,
|
||||||
|
required=False
|
||||||
|
)
|
||||||
|
@ -47,6 +47,7 @@ urlpatterns = [
|
|||||||
path('contacts/<int:pk>/', include(get_model_urls('tenancy', 'contact'))),
|
path('contacts/<int:pk>/', include(get_model_urls('tenancy', 'contact'))),
|
||||||
|
|
||||||
# Contact assignments
|
# Contact assignments
|
||||||
|
path('contact-assignments/', views.ContactAssignmentListView.as_view(), name='contactassignment_list'),
|
||||||
path('contact-assignments/add/', views.ContactAssignmentEditView.as_view(), name='contactassignment_add'),
|
path('contact-assignments/add/', views.ContactAssignmentEditView.as_view(), name='contactassignment_add'),
|
||||||
path('contact-assignments/<int:pk>/', include(get_model_urls('tenancy', 'contactassignment'))),
|
path('contact-assignments/<int:pk>/', include(get_model_urls('tenancy', 'contactassignment'))),
|
||||||
|
|
||||||
|
@ -366,6 +366,13 @@ class ContactBulkDeleteView(generic.BulkDeleteView):
|
|||||||
# Contact assignments
|
# Contact assignments
|
||||||
#
|
#
|
||||||
|
|
||||||
|
class ContactAssignmentListView(generic.ObjectListView):
|
||||||
|
queryset = ContactAssignment.objects.all()
|
||||||
|
filterset = filtersets.ContactAssignmentFilterSet
|
||||||
|
filterset_form = forms.ContactAssignmentFilterForm
|
||||||
|
table = tables.ContactAssignmentTable
|
||||||
|
|
||||||
|
|
||||||
@register_model_view(ContactAssignment, 'edit')
|
@register_model_view(ContactAssignment, 'edit')
|
||||||
class ContactAssignmentEditView(generic.ObjectEditView):
|
class ContactAssignmentEditView(generic.ObjectEditView):
|
||||||
queryset = ContactAssignment.objects.all()
|
queryset = ContactAssignment.objects.all()
|
||||||
|
Loading…
Reference in New Issue
Block a user