mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 04:02:52 -06:00
#11693: Clean up ExportTemplate model form
This commit is contained in:
parent
c35e7b8ee5
commit
d6afc125e5
@ -90,7 +90,7 @@ class CustomLinkForm(BootstrapMixin, forms.ModelForm):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class ExportTemplateForm(BootstrapMixin, forms.ModelForm):
|
class ExportTemplateForm(BootstrapMixin, SyncedDataMixin, forms.ModelForm):
|
||||||
content_types = ContentTypeMultipleChoiceField(
|
content_types = ContentTypeMultipleChoiceField(
|
||||||
queryset=ContentType.objects.all(),
|
queryset=ContentType.objects.all(),
|
||||||
limit_choices_to=FeatureQuery('export_templates')
|
limit_choices_to=FeatureQuery('export_templates')
|
||||||
@ -101,8 +101,8 @@ class ExportTemplateForm(BootstrapMixin, forms.ModelForm):
|
|||||||
)
|
)
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
('Export Template', ('name', 'content_types', 'description')),
|
('Export Template', ('name', 'content_types', 'description', 'template_code')),
|
||||||
('Content', ('data_source', 'data_file', 'template_code',)),
|
('Data Source', ('data_source', 'data_file')),
|
||||||
('Rendering', ('mime_type', 'file_extension', 'as_attachment')),
|
('Rendering', ('mime_type', 'file_extension', 'as_attachment')),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -110,6 +110,16 @@ class ExportTemplateForm(BootstrapMixin, forms.ModelForm):
|
|||||||
model = ExportTemplate
|
model = ExportTemplate
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
# Disable data field when a DataFile has been set
|
||||||
|
if self.instance.data_file:
|
||||||
|
self.fields['template_code'].widget.attrs['readonly'] = True
|
||||||
|
self.fields['template_code'].help_text = _(
|
||||||
|
'Template content is populated from the remote source selected below.'
|
||||||
|
)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
super().clean()
|
super().clean()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user