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

Added bulk import views for RIRs, roles, and VLAN groups

This commit is contained in:
Jeremy Stretch
2017-10-09 15:42:06 -04:00
parent 987587b5f3
commit 977cad3830
5 changed files with 69 additions and 4 deletions

View File

@@ -97,6 +97,17 @@ class RIRForm(BootstrapMixin, forms.ModelForm):
fields = ['name', 'slug', 'is_private']
class RIRCSVForm(forms.ModelForm):
slug = SlugField()
class Meta:
model = RIR
fields = ['name', 'slug', 'is_private']
help_texts = {
'name': 'RIR name',
}
class RIRFilterForm(BootstrapMixin, forms.Form):
is_private = forms.NullBooleanField(required=False, label='Private', widget=forms.Select(choices=[
('', '---------'),
@@ -169,6 +180,17 @@ class RoleForm(BootstrapMixin, forms.ModelForm):
fields = ['name', 'slug']
class RoleCSVForm(forms.ModelForm):
slug = SlugField()
class Meta:
model = Role
fields = ['name', 'slug']
help_texts = {
'name': 'Role name',
}
#
# Prefixes
#
@@ -718,6 +740,26 @@ class VLANGroupForm(BootstrapMixin, forms.ModelForm):
fields = ['site', 'name', 'slug']
class VLANGroupCSVForm(forms.ModelForm):
site = forms.ModelChoiceField(
queryset=Site.objects.all(),
required=False,
to_field_name='name',
help_text='Name of parent site',
error_messages={
'invalid_choice': 'Site not found.',
}
)
slug = SlugField()
class Meta:
model = VLANGroup
fields = ['site', 'name', 'slug']
help_texts = {
'name': 'Name of VLAN group',
}
class VLANGroupFilterForm(BootstrapMixin, forms.Form):
site = FilterChoiceField(
queryset=Site.objects.annotate(filter_count=Count('vlan_groups')),