Added support for group assignment during VLAN import

This commit is contained in:
Jeremy Stretch
2016-07-18 11:59:55 -04:00
parent d201dad535
commit cb4643d810
2 changed files with 9 additions and 2 deletions

View File

@@ -503,13 +503,15 @@ class VLANForm(forms.ModelForm, BootstrapMixin):
class VLANFromCSVForm(forms.ModelForm):
site = forms.ModelChoiceField(queryset=Site.objects.all(), to_field_name='name',
error_messages={'invalid_choice': 'Device not found.'})
group = forms.ModelChoiceField(queryset=VLANGroup.objects.all(), required=False, to_field_name='name',
error_messages={'invalid_choice': 'VLAN group not found.'})
status_name = forms.ChoiceField(choices=[(s[1], s[0]) for s in VLAN_STATUS_CHOICES])
role = forms.ModelChoiceField(queryset=Role.objects.all(), required=False, to_field_name='name',
error_messages={'invalid_choice': 'Invalid role.'})
class Meta:
model = VLAN
fields = ['site', 'vid', 'name', 'status_name', 'role']
fields = ['site', 'group', 'vid', 'name', 'status_name', 'role']
def save(self, *args, **kwargs):
m = super(VLANFromCSVForm, self).save(commit=False)