mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-22 19:48:45 -06:00
Adds tags on contact assignment (#13328)
* adds tags on contact assignments #12882 * updated migration * added tags on import form * adds TagsMixin on ContactAssignmentType #12882 * Misc cleanup --------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
committed by
GitHub
parent
c1ca8d5d8d
commit
cbf4b43b35
@@ -106,9 +106,6 @@ class ContactAssignmentImportForm(NetBoxModelImportForm):
|
||||
help_text=_('Assigned role')
|
||||
)
|
||||
|
||||
# Remove the tags field added by NetBoxModelImportForm (unsupported by ContactAssignment)
|
||||
tags = None
|
||||
|
||||
class Meta:
|
||||
model = ContactAssignment
|
||||
fields = ('content_type', 'object_id', 'contact', 'priority', 'role')
|
||||
|
||||
@@ -83,7 +83,7 @@ class ContactFilterForm(NetBoxModelFilterSetForm):
|
||||
class ContactAssignmentFilterForm(NetBoxModelFilterSetForm):
|
||||
model = ContactAssignment
|
||||
fieldsets = (
|
||||
(None, ('q', 'filter_id')),
|
||||
(None, ('q', 'filter_id', 'tag')),
|
||||
(_('Assignment'), ('content_type_id', 'group_id', 'contact_id', 'role_id', 'priority')),
|
||||
)
|
||||
content_type_id = ContentTypeMultipleChoiceField(
|
||||
@@ -112,3 +112,4 @@ class ContactAssignmentFilterForm(NetBoxModelFilterSetForm):
|
||||
choices=ContactPriorityChoices,
|
||||
required=False
|
||||
)
|
||||
tag = TagFilterField(model)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
from django import forms
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from extras.models import Tag
|
||||
from netbox.forms import NetBoxModelForm
|
||||
from tenancy.models import *
|
||||
from utilities.forms import BootstrapMixin
|
||||
from utilities.forms.fields import CommentField, DynamicModelChoiceField, SlugField
|
||||
from utilities.forms.fields import CommentField, DynamicModelChoiceField, DynamicModelMultipleChoiceField, SlugField
|
||||
|
||||
__all__ = (
|
||||
'ContactAssignmentForm',
|
||||
@@ -140,11 +141,16 @@ class ContactAssignmentForm(BootstrapMixin, forms.ModelForm):
|
||||
label=_('Role'),
|
||||
queryset=ContactRole.objects.all()
|
||||
)
|
||||
tags = DynamicModelMultipleChoiceField(
|
||||
queryset=Tag.objects.all(),
|
||||
required=False,
|
||||
label=_('Tags')
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = ContactAssignment
|
||||
fields = (
|
||||
'content_type', 'object_id', 'group', 'contact', 'role', 'priority',
|
||||
'content_type', 'object_id', 'group', 'contact', 'role', 'priority', 'tags'
|
||||
)
|
||||
widgets = {
|
||||
'content_type': forms.HiddenInput(),
|
||||
|
||||
Reference in New Issue
Block a user