mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-20 02:06:42 -06:00
Closes #716: Add ASN field to site bulk edit form
This commit is contained in:
parent
9fd9719d0b
commit
96de61ddfb
@ -91,9 +91,10 @@ class SiteImportForm(BulkImportForm, BootstrapMixin):
|
|||||||
class SiteBulkEditForm(BootstrapMixin, CustomFieldBulkEditForm):
|
class SiteBulkEditForm(BootstrapMixin, CustomFieldBulkEditForm):
|
||||||
pk = forms.ModelMultipleChoiceField(queryset=Site.objects.all(), widget=forms.MultipleHiddenInput)
|
pk = forms.ModelMultipleChoiceField(queryset=Site.objects.all(), widget=forms.MultipleHiddenInput)
|
||||||
tenant = forms.ModelChoiceField(queryset=Tenant.objects.all(), required=False)
|
tenant = forms.ModelChoiceField(queryset=Tenant.objects.all(), required=False)
|
||||||
|
asn = forms.IntegerField(min_value=1, max_value=4294967295, required=False, label='ASN')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
nullable_fields = ['tenant']
|
nullable_fields = ['tenant', 'asn']
|
||||||
|
|
||||||
|
|
||||||
class SiteFilterForm(BootstrapMixin, CustomFieldFilterForm):
|
class SiteFilterForm(BootstrapMixin, CustomFieldFilterForm):
|
||||||
|
@ -7,7 +7,7 @@ from django.core.exceptions import ImproperlyConfigured, ValidationError
|
|||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.db import transaction, IntegrityError
|
from django.db import transaction, IntegrityError
|
||||||
from django.db.models import ProtectedError
|
from django.db.models import ProtectedError
|
||||||
from django.forms import ModelMultipleChoiceField, MultipleHiddenInput, TypedChoiceField
|
from django.forms import CharField, ModelMultipleChoiceField, MultipleHiddenInput, TypedChoiceField
|
||||||
from django.http import HttpResponse, HttpResponseRedirect
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
from django.shortcuts import get_object_or_404, redirect, render
|
from django.shortcuts import get_object_or_404, redirect, render
|
||||||
from django.template import TemplateSyntaxError
|
from django.template import TemplateSyntaxError
|
||||||
@ -398,7 +398,10 @@ class BulkEditView(View):
|
|||||||
fields_to_update = {}
|
fields_to_update = {}
|
||||||
for field in standard_fields:
|
for field in standard_fields:
|
||||||
if field in form.nullable_fields and field in nullified_fields:
|
if field in form.nullable_fields and field in nullified_fields:
|
||||||
fields_to_update[field] = ''
|
if isinstance(form.fields[field], CharField):
|
||||||
|
fields_to_update[field] = ''
|
||||||
|
else:
|
||||||
|
fields_to_update[field] = None
|
||||||
elif form.cleaned_data[field]:
|
elif form.cleaned_data[field]:
|
||||||
fields_to_update[field] = form.cleaned_data[field]
|
fields_to_update[field] = form.cleaned_data[field]
|
||||||
updated_count = self.cls.objects.filter(pk__in=pk_list).update(**fields_to_update)
|
updated_count = self.cls.objects.filter(pk__in=pk_list).update(**fields_to_update)
|
||||||
|
Loading…
Reference in New Issue
Block a user