1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

#11559: Add device config API endpoint & cleanup

This commit is contained in:
jeremystretch
2023-03-21 17:00:06 -04:00
parent d6afc125e5
commit 00088cba6d
11 changed files with 154 additions and 65 deletions

View File

@@ -306,12 +306,26 @@ class ConfigTemplateForm(BootstrapMixin, SyncedDataMixin, forms.ModelForm):
fieldsets = (
('Config Template', ('name', 'description', 'environment_params', 'tags')),
('Content', ('data_source', 'data_file', 'template_code',)),
('Content', ('template_code',)),
('Data Source', ('data_source', 'data_file')),
)
class Meta:
model = ConfigTemplate
fields = '__all__'
widgets = {
'environment_params': forms.Textarea(attrs={'rows': 5})
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Disable content 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):
super().clean()