mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Extend DeviceType import to include related objects
This commit is contained in:
@@ -297,6 +297,7 @@ class APISelect(SelectWithDisabled):
|
||||
conditional_query_params=None,
|
||||
additional_query_params=None,
|
||||
null_option=False,
|
||||
full=False,
|
||||
*args,
|
||||
**kwargs
|
||||
):
|
||||
@@ -305,6 +306,8 @@ class APISelect(SelectWithDisabled):
|
||||
|
||||
self.attrs['class'] = 'netbox-select2-api'
|
||||
self.attrs['data-url'] = '/{}{}'.format(settings.BASE_PATH, api_url.lstrip('/')) # Inject BASE_PATH
|
||||
if full:
|
||||
self.attrs['data-full'] = full
|
||||
if display_field:
|
||||
self.attrs['display-field'] = display_field
|
||||
if value_field:
|
||||
@@ -380,7 +383,7 @@ class CSVDataField(forms.CharField):
|
||||
|
||||
self.strip = False
|
||||
if not self.label:
|
||||
self.label = 'CSV Data'
|
||||
self.label = ''
|
||||
if not self.initial:
|
||||
self.initial = ','.join(required_fields) + '\n'
|
||||
if not self.help_text:
|
||||
@@ -480,7 +483,7 @@ class CommentField(forms.CharField):
|
||||
A textarea with support for GitHub-Flavored Markdown. Exists mostly just to add a standard help_text.
|
||||
"""
|
||||
widget = forms.Textarea
|
||||
default_label = 'Comments'
|
||||
default_label = ''
|
||||
# TODO: Port GFM syntax cheat sheet to internal documentation
|
||||
default_helptext = '<i class="fa fa-info-circle"></i> '\
|
||||
'<a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank">'\
|
||||
@@ -563,10 +566,9 @@ class MultiObjectField(forms.Field):
|
||||
|
||||
def clean(self, value):
|
||||
|
||||
for obj in value:
|
||||
subform = self.form(obj)
|
||||
if not subform.is_valid():
|
||||
raise forms.ValidationError(mark_safe(subform.errors.items()))
|
||||
# Value needs to be an iterable
|
||||
if value is None:
|
||||
return list()
|
||||
|
||||
return value
|
||||
|
||||
|
||||
Reference in New Issue
Block a user