dashboard: change clean method in create and update

When a user create or edit a BGP VPN, the attributes
RTs are still sent in the API request even if the
related fields are empty.
This path change this behavior. So, in the form, if the
RTs fields are empty, the attributes aren't sent in
the API request.
Change-Id: I93e68f16aed31ea8ad99579e3cd7cb498bf85e14
This commit is contained in:
Cédric Savignan
2017年07月04日 15:18:58 +02:00
parent 6b57aed6e8
commit 9eaf1b159f

View File

@@ -51,7 +51,10 @@ class CommonData(forms.SelfHandlingForm):
if self.request.user.is_superuser:
for attribute in bgpvpn_common.RT_FORMAT_ATTRIBUTES:
if not cleaned_data.get(attribute):
cleaned_data[attribute] = None
del cleaned_data[attribute]
else:
cleaned_data[attribute] = bgpvpn_common.format_rt(
cleaned_data[attribute])
# if an admin user use the bgpvpn panel project
# tenant_id field doesn't exist
if not cleaned_data.get('tenant_id'):
@@ -75,9 +78,6 @@ class CommonData(forms.SelfHandlingForm):
def handle(self, request, data):
params = {}
if request.user.is_superuser:
for key in bgpvpn_common.RT_FORMAT_ATTRIBUTES:
params[key] = bgpvpn_common.format_rt(data.pop(key))
params.update(data)
try:
if self.action == 'update':
Reference in New Issue
openstack/networking-bgpvpn
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.

The note is not visible to the blocked user.