Skip to content
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
81707a1
Feat: added data_source & data_file fields for ConfigTemplate import …
Oct 31, 2025
b3cfc7c
Merge branch 'netbox-community:main' into 20731-add-data_file-data_so…
ifoughal Nov 3, 2025
0fa1156
Merge branch 'netbox-community:main' into 20731-add-data_file-data_so…
ifoughal Nov 10, 2025
0340b80
Style: fixed linter issues
ifoughal Nov 12, 2025
7bf0158
Merge branch '20731-add-data_file-data_source-to-config_template-bulk…
ifoughal Nov 12, 2025
d8c2119
Merge branch 'netbox-community:main' into 20731-add-data_file-data_so…
ifoughal Nov 13, 2025
6e92fc0
revert: Restore blank line between import groups in bulk_import.py
ifoughal Nov 13, 2025
1662a4f
revert: Restored comma in grouped import
ifoughal Nov 13, 2025
da34c60
Feat: combined core.models imports
ifoughal Nov 13, 2025
0823015
Revert: not in FR scope
ifoughal Nov 13, 2025
e0c012a
Feat: renamed label to human-friendly
ifoughal Nov 13, 2025
dc61f59
Feat: enhanced helper text
ifoughal Nov 13, 2025
6f31188
Style: removed blank lines between attributes
ifoughal Nov 13, 2025
0b233b4
Feat: renamed data_file label to human-friendly
ifoughal Nov 13, 2025
1de7ecd
Feat: enhanced helper text of data_file attribute
ifoughal Nov 13, 2025
aa4a7aa
Feat: removed already supported template_code attribute from ConfigTe…
ifoughal Nov 13, 2025
dd3ce38
Style: capitalized label for auto_sync_enabled
ifoughal Nov 13, 2025
1b1d7fb
Style: enhanced helper text for auto_sync_enabled attribute
ifoughal Nov 13, 2025
e20ab14
Style: 120 chars line collapse
ifoughal Nov 13, 2025
41d5e13
Feat: moved clean_template_code logic to clean method
ifoughal Nov 13, 2025
2871944
Feat: removed uncessary clean on boolean attribute
ifoughal Nov 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions netbox/extras/forms/bulk_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.core.exceptions import ObjectDoesNotExist
from django.utils.translation import gettext_lazy as _

from core.models import ObjectType
from core.models import ObjectType, DataSource, DataFile
from extras.choices import *
from extras.models import *
from netbox.events import get_event_type_choices
Expand Down Expand Up @@ -160,14 +160,41 @@ class Meta:


class ConfigTemplateImportForm(CSVModelForm):
data_source = CSVModelChoiceField(
label=_('Data source'),
queryset=DataSource.objects.all(),
required=False,
to_field_name='name',
help_text=_('Data source which provides the data file')
)
data_file = CSVModelChoiceField(
label=_('Data file'),
queryset=DataFile.objects.all(),
required=False,
to_field_name='path',
help_text=_('Data file containing the template code')
)
auto_sync_enabled = forms.BooleanField(
required=False,
label=_('Auto sync enabled'),
help_text=_("Enable automatic synchronization of template content when the data file is updated")
)

class Meta:
model = ConfigTemplate
fields = (
'name', 'description', 'template_code', 'environment_params', 'mime_type', 'file_name', 'file_extension',
'as_attachment', 'tags',
fields = (
'name', 'description', 'template_code', 'data_source', 'data_file', 'auto_sync_enabled',
'environment_params', 'mime_type', 'file_name', 'file_extension', 'as_attachment', 'tags',
)

def clean(self):
super().clean()

# Make sure template_code is None when it's not included in the uploaded data
if not self.data.get('template_code') and not self.data.get('data_file'):
raise forms.ValidationError(_("Must specify either local content or a data file"))
return self.cleaned_data['template_code']


class SavedFilterImportForm(CSVModelForm):
object_types = CSVMultipleContentTypeField(
Expand Down