Closes #20304: Object owners (#20634)
CI / build (20.x, 3.12) (push) Has been cancelled
CI / build (20.x, 3.13) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, actions) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled

This commit is contained in:
Jeremy Stretch
2025-10-24 16:08:01 -04:00
committed by GitHub
parent 52d4498caf
commit be74436884
196 changed files with 15831 additions and 2715 deletions
+21 -21
View File
@@ -9,7 +9,7 @@ from core.models import ObjectType
from extras.choices import *
from extras.models import *
from netbox.events import get_event_type_choices
from netbox.forms import NetBoxModelImportForm
from netbox.forms import NetBoxModelImportForm, OwnerCSVMixin, PrimaryModelImportForm
from users.models import Group, User
from utilities.forms import CSVModelForm
from utilities.forms.fields import (
@@ -33,7 +33,7 @@ __all__ = (
)
class CustomFieldImportForm(CSVModelForm):
class CustomFieldImportForm(OwnerCSVMixin, CSVModelForm):
object_types = CSVMultipleContentTypeField(
label=_('Object types'),
queryset=ObjectType.objects.with_feature('custom_fields'),
@@ -75,11 +75,11 @@ class CustomFieldImportForm(CSVModelForm):
fields = (
'name', 'label', 'group_name', 'type', 'object_types', 'related_object_type', 'required', 'unique',
'description', 'search_weight', 'filter_logic', 'default', 'choice_set', 'weight', 'validation_minimum',
'validation_maximum', 'validation_regex', 'ui_visible', 'ui_editable', 'is_cloneable', 'comments',
'validation_maximum', 'validation_regex', 'ui_visible', 'ui_editable', 'is_cloneable', 'owner', 'comments',
)
class CustomFieldChoiceSetImportForm(CSVModelForm):
class CustomFieldChoiceSetImportForm(OwnerCSVMixin, CSVModelForm):
base_choices = CSVChoiceField(
choices=CustomFieldChoiceSetBaseChoices,
required=False,
@@ -97,7 +97,7 @@ class CustomFieldChoiceSetImportForm(CSVModelForm):
class Meta:
model = CustomFieldChoiceSet
fields = (
'name', 'description', 'base_choices', 'extra_choices', 'order_alphabetically',
'name', 'description', 'base_choices', 'extra_choices', 'order_alphabetically', 'owner',
)
def clean_extra_choices(self):
@@ -114,7 +114,7 @@ class CustomFieldChoiceSetImportForm(CSVModelForm):
return data
class CustomLinkImportForm(CSVModelForm):
class CustomLinkImportForm(OwnerCSVMixin, CSVModelForm):
object_types = CSVMultipleContentTypeField(
label=_('Object types'),
queryset=ObjectType.objects.with_feature('custom_links'),
@@ -131,11 +131,11 @@ class CustomLinkImportForm(CSVModelForm):
model = CustomLink
fields = (
'name', 'object_types', 'enabled', 'weight', 'group_name', 'button_class', 'new_window', 'link_text',
'link_url',
'link_url', 'owner',
)
class ExportTemplateImportForm(CSVModelForm):
class ExportTemplateImportForm(OwnerCSVMixin, CSVModelForm):
object_types = CSVMultipleContentTypeField(
label=_('Object types'),
queryset=ObjectType.objects.with_feature('export_templates'),
@@ -146,30 +146,30 @@ class ExportTemplateImportForm(CSVModelForm):
model = ExportTemplate
fields = (
'name', 'object_types', 'description', 'environment_params', 'mime_type', 'file_name', 'file_extension',
'as_attachment', 'template_code',
'as_attachment', 'template_code', 'owner',
)
class ConfigContextProfileImportForm(NetBoxModelImportForm):
class ConfigContextProfileImportForm(PrimaryModelImportForm):
class Meta:
model = ConfigContextProfile
fields = [
'name', 'description', 'schema', 'comments', 'tags',
'name', 'description', 'schema', 'owner', 'comments', 'tags',
]
class ConfigTemplateImportForm(CSVModelForm):
class ConfigTemplateImportForm(OwnerCSVMixin, CSVModelForm):
class Meta:
model = ConfigTemplate
fields = (
'name', 'description', 'template_code', 'environment_params', 'mime_type', 'file_name', 'file_extension',
'as_attachment', 'tags',
'as_attachment', 'owner', 'tags',
)
class SavedFilterImportForm(CSVModelForm):
class SavedFilterImportForm(OwnerCSVMixin, CSVModelForm):
object_types = CSVMultipleContentTypeField(
label=_('Object types'),
queryset=ObjectType.objects.all(),
@@ -179,21 +179,21 @@ class SavedFilterImportForm(CSVModelForm):
class Meta:
model = SavedFilter
fields = (
'name', 'slug', 'object_types', 'description', 'weight', 'enabled', 'shared', 'parameters',
'name', 'slug', 'object_types', 'description', 'weight', 'enabled', 'shared', 'parameters', 'owner',
)
class WebhookImportForm(NetBoxModelImportForm):
class WebhookImportForm(OwnerCSVMixin, NetBoxModelImportForm):
class Meta:
model = Webhook
fields = (
'name', 'payload_url', 'http_method', 'http_content_type', 'additional_headers', 'body_template',
'secret', 'ssl_verification', 'ca_file_path', 'description', 'tags'
'secret', 'ssl_verification', 'ca_file_path', 'description', 'owner', 'tags'
)
class EventRuleImportForm(NetBoxModelImportForm):
class EventRuleImportForm(OwnerCSVMixin, NetBoxModelImportForm):
object_types = CSVMultipleContentTypeField(
label=_('Object types'),
queryset=ObjectType.objects.with_feature('event_rules'),
@@ -214,7 +214,7 @@ class EventRuleImportForm(NetBoxModelImportForm):
model = EventRule
fields = (
'name', 'description', 'enabled', 'conditions', 'object_types', 'event_types', 'action_type',
'comments', 'tags'
'owner', 'comments', 'tags'
)
def clean(self):
@@ -242,7 +242,7 @@ class EventRuleImportForm(NetBoxModelImportForm):
self.instance.action_object_type = ObjectType.objects.get_for_model(script, for_concrete_model=False)
class TagImportForm(CSVModelForm):
class TagImportForm(OwnerCSVMixin, CSVModelForm):
slug = SlugField()
weight = forms.IntegerField(
label=_('Weight'),
@@ -258,7 +258,7 @@ class TagImportForm(CSVModelForm):
class Meta:
model = Tag
fields = (
'name', 'slug', 'color', 'weight', 'description', 'object_types',
'name', 'slug', 'color', 'weight', 'description', 'object_types', 'owner',
)