mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-27 07:37:45 -06:00
Introduce ServiceTemplate
This commit is contained in:
@@ -23,6 +23,7 @@ __all__ = (
|
||||
'RoleBulkEditForm',
|
||||
'RouteTargetBulkEditForm',
|
||||
'ServiceBulkEditForm',
|
||||
'ServiceTemplateBulkEditForm',
|
||||
'VLANBulkEditForm',
|
||||
'VLANGroupBulkEditForm',
|
||||
'VRFBulkEditForm',
|
||||
@@ -433,9 +434,9 @@ class VLANBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
|
||||
]
|
||||
|
||||
|
||||
class ServiceBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
|
||||
class ServiceTemplateBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
|
||||
pk = forms.ModelMultipleChoiceField(
|
||||
queryset=Service.objects.all(),
|
||||
queryset=ServiceTemplate.objects.all(),
|
||||
widget=forms.MultipleHiddenInput()
|
||||
)
|
||||
protocol = forms.ChoiceField(
|
||||
@@ -459,3 +460,10 @@ class ServiceBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
|
||||
nullable_fields = [
|
||||
'description',
|
||||
]
|
||||
|
||||
|
||||
class ServiceBulkEditForm(ServiceTemplateBulkEditForm):
|
||||
pk = forms.ModelMultipleChoiceField(
|
||||
queryset=Service.objects.all(),
|
||||
widget=forms.MultipleHiddenInput()
|
||||
)
|
||||
|
||||
@@ -21,6 +21,7 @@ __all__ = (
|
||||
'RoleCSVForm',
|
||||
'RouteTargetCSVForm',
|
||||
'ServiceCSVForm',
|
||||
'ServiceTemplateCSVForm',
|
||||
'VLANCSVForm',
|
||||
'VLANGroupCSVForm',
|
||||
'VRFCSVForm',
|
||||
@@ -392,6 +393,17 @@ class VLANCSVForm(CustomFieldModelCSVForm):
|
||||
}
|
||||
|
||||
|
||||
class ServiceTemplateCSVForm(CustomFieldModelCSVForm):
|
||||
protocol = CSVChoiceField(
|
||||
choices=ServiceProtocolChoices,
|
||||
help_text='IP protocol'
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = ServiceTemplate
|
||||
fields = ('name', 'protocol', 'ports', 'description')
|
||||
|
||||
|
||||
class ServiceCSVForm(CustomFieldModelCSVForm):
|
||||
device = CSVModelChoiceField(
|
||||
queryset=Device.objects.all(),
|
||||
|
||||
@@ -24,6 +24,7 @@ __all__ = (
|
||||
'RoleFilterForm',
|
||||
'RouteTargetFilterForm',
|
||||
'ServiceFilterForm',
|
||||
'ServiceTemplateFilterForm',
|
||||
'VLANFilterForm',
|
||||
'VLANGroupFilterForm',
|
||||
'VRFFilterForm',
|
||||
@@ -447,8 +448,8 @@ class VLANFilterForm(TenancyFilterForm, CustomFieldModelFilterForm):
|
||||
tag = TagFilterField(model)
|
||||
|
||||
|
||||
class ServiceFilterForm(CustomFieldModelFilterForm):
|
||||
model = Service
|
||||
class ServiceTemplateFilterForm(CustomFieldModelFilterForm):
|
||||
model = ServiceTemplate
|
||||
field_groups = (
|
||||
('q', 'tag'),
|
||||
('protocol', 'port'),
|
||||
@@ -462,3 +463,7 @@ class ServiceFilterForm(CustomFieldModelFilterForm):
|
||||
required=False,
|
||||
)
|
||||
tag = TagFilterField(model)
|
||||
|
||||
|
||||
class ServiceFilterForm(ServiceTemplateFilterForm):
|
||||
model = Service
|
||||
|
||||
@@ -31,6 +31,7 @@ __all__ = (
|
||||
'RoleForm',
|
||||
'RouteTargetForm',
|
||||
'ServiceForm',
|
||||
'ServiceTemplateForm',
|
||||
'VLANForm',
|
||||
'VLANGroupForm',
|
||||
'VRFForm',
|
||||
@@ -815,6 +816,27 @@ class VLANForm(TenancyForm, CustomFieldModelForm):
|
||||
}
|
||||
|
||||
|
||||
class ServiceTemplateForm(CustomFieldModelForm):
|
||||
ports = NumericArrayField(
|
||||
base_field=forms.IntegerField(
|
||||
min_value=SERVICE_PORT_MIN,
|
||||
max_value=SERVICE_PORT_MAX
|
||||
),
|
||||
help_text="Comma-separated list of one or more port numbers. A range may be specified using a hyphen."
|
||||
)
|
||||
tags = DynamicModelMultipleChoiceField(
|
||||
queryset=Tag.objects.all(),
|
||||
required=False
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = ServiceTemplate
|
||||
fields = ('name', 'protocol', 'ports', 'description', 'tags')
|
||||
widgets = {
|
||||
'protocol': StaticSelect(),
|
||||
}
|
||||
|
||||
|
||||
class ServiceForm(CustomFieldModelForm):
|
||||
device = DynamicModelChoiceField(
|
||||
queryset=Device.objects.all(),
|
||||
|
||||
Reference in New Issue
Block a user