1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #11541: Support for limiting tag assignments by object type (#12982)

* Initial work on #11541

* Merge migrations

* Limit tags by object type during assignment

* Add tests for object type validation

* Fix form field parameters
This commit is contained in:
Jeremy Stretch
2023-06-23 14:08:14 -04:00
committed by GitHub
parent 69b818ed33
commit 1056e513b1
14 changed files with 156 additions and 27 deletions

View File

@@ -204,15 +204,20 @@ class WebhookForm(BootstrapMixin, forms.ModelForm):
class TagForm(BootstrapMixin, forms.ModelForm):
slug = SlugField()
object_types = ContentTypeMultipleChoiceField(
queryset=ContentType.objects.all(),
limit_choices_to=FeatureQuery('tags'),
required=False
)
fieldsets = (
('Tag', ('name', 'slug', 'color', 'description')),
('Tag', ('name', 'slug', 'color', 'description', 'object_types')),
)
class Meta:
model = Tag
fields = [
'name', 'slug', 'color', 'description'
'name', 'slug', 'color', 'description', 'object_types',
]