From 9eaf1b159f1cb1aece5b53867814fa6fccd63635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Savignan?= Date: Tue, 4 Jul 2017 15:18:58 +0200 Subject: [PATCH] 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 --- bgpvpn_dashboard/dashboards/project/bgpvpn/forms.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bgpvpn_dashboard/dashboards/project/bgpvpn/forms.py b/bgpvpn_dashboard/dashboards/project/bgpvpn/forms.py index f15279c7..113bd0c0 100755 --- a/bgpvpn_dashboard/dashboards/project/bgpvpn/forms.py +++ b/bgpvpn_dashboard/dashboards/project/bgpvpn/forms.py @@ -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':

AltStyle によって変換されたページ (->オリジナル) /