1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00
This commit is contained in:
jeremystretch
2022-11-15 12:09:03 -05:00
parent 6f8a7fdbe3
commit d9d25ff4e7
4 changed files with 31 additions and 50 deletions

View File

@ -23,6 +23,7 @@ __all__ = (
'DeviceBayCSVForm', 'DeviceBayCSVForm',
'DeviceCSVForm', 'DeviceCSVForm',
'DeviceRoleCSVForm', 'DeviceRoleCSVForm',
'DeviceTypeImportForm',
'FrontPortCSVForm', 'FrontPortCSVForm',
'InterfaceCSVForm', 'InterfaceCSVForm',
'InventoryItemCSVForm', 'InventoryItemCSVForm',
@ -31,6 +32,7 @@ __all__ = (
'ManufacturerCSVForm', 'ManufacturerCSVForm',
'ModuleCSVForm', 'ModuleCSVForm',
'ModuleBayCSVForm', 'ModuleBayCSVForm',
'ModuleTypeImportForm',
'PlatformCSVForm', 'PlatformCSVForm',
'PowerFeedCSVForm', 'PowerFeedCSVForm',
'PowerOutletCSVForm', 'PowerOutletCSVForm',
@ -269,6 +271,31 @@ class ManufacturerCSVForm(NetBoxModelCSVForm):
fields = ('name', 'slug', 'description', 'tags') fields = ('name', 'slug', 'description', 'tags')
class DeviceTypeImportForm(NetBoxModelCSVForm):
manufacturer = forms.ModelChoiceField(
queryset=Manufacturer.objects.all(),
to_field_name='name'
)
class Meta:
model = DeviceType
fields = [
'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow',
'description', 'comments',
]
class ModuleTypeImportForm(NetBoxModelCSVForm):
manufacturer = forms.ModelChoiceField(
queryset=Manufacturer.objects.all(),
to_field_name='name'
)
class Meta:
model = ModuleType
fields = ['manufacturer', 'model', 'part_number', 'description', 'comments']
class DeviceRoleCSVForm(NetBoxModelCSVForm): class DeviceRoleCSVForm(NetBoxModelCSVForm):
slug = SlugField() slug = SlugField()

View File

@ -9,43 +9,16 @@ __all__ = (
'ConsolePortTemplateImportForm', 'ConsolePortTemplateImportForm',
'ConsoleServerPortTemplateImportForm', 'ConsoleServerPortTemplateImportForm',
'DeviceBayTemplateImportForm', 'DeviceBayTemplateImportForm',
'DeviceTypeImportForm',
'FrontPortTemplateImportForm', 'FrontPortTemplateImportForm',
'InterfaceTemplateImportForm', 'InterfaceTemplateImportForm',
'InventoryItemTemplateImportForm', 'InventoryItemTemplateImportForm',
'ModuleBayTemplateImportForm', 'ModuleBayTemplateImportForm',
'ModuleTypeImportForm',
'PowerOutletTemplateImportForm', 'PowerOutletTemplateImportForm',
'PowerPortTemplateImportForm', 'PowerPortTemplateImportForm',
'RearPortTemplateImportForm', 'RearPortTemplateImportForm',
) )
class DeviceTypeImportForm(BootstrapMixin, forms.ModelForm):
manufacturer = forms.ModelChoiceField(
queryset=Manufacturer.objects.all(),
to_field_name='name'
)
class Meta:
model = DeviceType
fields = [
'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow',
'description', 'comments',
]
class ModuleTypeImportForm(BootstrapMixin, forms.ModelForm):
manufacturer = forms.ModelChoiceField(
queryset=Manufacturer.objects.all(),
to_field_name='name'
)
class Meta:
model = ModuleType
fields = ['manufacturer', 'model', 'part_number', 'description', 'comments']
# #
# Component template import forms # Component template import forms
# #

View File

@ -63,6 +63,10 @@ class NetBoxModelCSVForm(CSVModelForm, NetBoxModelForm):
""" """
Base form for creating a NetBox objects from CSV data. Used for bulk importing. Base form for creating a NetBox objects from CSV data. Used for bulk importing.
""" """
id = forms.IntegerField(
required=False,
help_text='Numeric ID of an existing object to update (if not creating a new object)'
)
tags = CSVModelMultipleChoiceField( tags = CSVModelMultipleChoiceField(
queryset=Tag.objects.all(), queryset=Tag.objects.all(),
required=False, required=False,

View File

@ -1,23 +0,0 @@
{% extends 'base/layout.html' %}
{% load helpers %}
{% load form_helpers %}
{% block title %}{{ obj_type|bettertitle }} Import{% endblock %}
{% block content %}
<div class="row mb-3">
<div class="col col-md-12 col-xl-8 offset-xl-2">
<form action="" method="post" class="form form-horizontal">
{% csrf_token %}
{% render_form form %}
<div class="col col-md-12 text-end">
<button type="submit" name="_create" class="btn btn-primary">Submit</button>
<button type="submit" name="_addanother" class="btn btn-outline-primary">Submit & Import Another</button>
{% if return_url %}
<a href="{{ return_url }}" class="btn btn-outline-danger">Cancel</a>
{% endif %}
</div>
</form>
</div>
</div>
{% endblock content %}