Remove function order_fields
Django also has a function named 'order_fields' [1], when we try to create service mappings or update pyscripts from dashboard, that function is called and an error occurs because of unmatched arguments. This patch removes that function from cloudkitty-dashboard and use the one defined in django since they have same effect. [1] https://github.com/django/django/blob/master/django/forms/forms.py#L114 Change-Id: If9e4b534c64046f93fc3d4b62d16b61dcd4558f3 Closes-bug: #1715810 Story: 2001181 Task: 4916
This commit is contained in:
parent
ccb1c3831b
commit
f4cd040748
|
@ -19,7 +19,6 @@ from horizon import forms
|
|||
|
||||
from cloudkittyclient.apiclient import exceptions
|
||||
from cloudkittydashboard.api import cloudkitty as api
|
||||
from cloudkittydashboard.dashboards import common
|
||||
|
||||
from openstack_dashboard import api as api_keystone
|
||||
|
||||
|
@ -71,7 +70,7 @@ class CreateServiceForm(forms.SelfHandlingForm):
|
|||
self.fields['service'].choices = choices
|
||||
|
||||
|
||||
class CreateFieldForm(forms.SelfHandlingForm, common.OrderFieldsMixin):
|
||||
class CreateFieldForm(forms.SelfHandlingForm):
|
||||
service_id = forms.CharField(label=_("Service ID"),
|
||||
widget=forms.TextInput(
|
||||
attrs={'readonly': 'readonly'}))
|
||||
|
@ -120,7 +119,7 @@ class CreateGroupForm(forms.SelfHandlingForm):
|
|||
return api.cloudkittyclient(request).hashmap.groups.create(name=name)
|
||||
|
||||
|
||||
class BaseForm(forms.SelfHandlingForm, common.OrderFieldsMixin):
|
||||
class BaseForm(forms.SelfHandlingForm):
|
||||
type = forms.ChoiceField(label=_("Type"),
|
||||
choices=(("flat", _("Flat")),
|
||||
("rate", _("Rate"))))
|
||||
|
@ -135,7 +134,7 @@ class BaseForm(forms.SelfHandlingForm, common.OrderFieldsMixin):
|
|||
|
||||
def __init__(self, request, *args, **kwargs):
|
||||
super(BaseForm, self).__init__(request, *args, **kwargs)
|
||||
self.order_fields()
|
||||
self.order_fields(self.fields_order)
|
||||
groups = api.cloudkittyclient(request).hashmap.groups.list()
|
||||
groups = api.identify(groups)
|
||||
choices = [(group.id, group.name) for group in groups]
|
||||
|
|
|
@ -19,7 +19,6 @@ from django.utils.translation import ugettext_lazy as _
|
|||
from horizon import forms
|
||||
|
||||
from cloudkittydashboard.api import cloudkitty as api
|
||||
from cloudkittydashboard.dashboards import common
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -99,7 +98,7 @@ class CreateScriptForm(forms.SelfHandlingForm):
|
|||
data=data['script_data'])
|
||||
|
||||
|
||||
class EditScriptForm(CreateScriptForm, common.OrderFieldsMixin):
|
||||
class EditScriptForm(CreateScriptForm):
|
||||
script_id = forms.CharField(label=_("Script ID"),
|
||||
widget=forms.TextInput(
|
||||
attrs={'readonly': 'readonly'}))
|
||||
|
@ -108,7 +107,7 @@ class EditScriptForm(CreateScriptForm, common.OrderFieldsMixin):
|
|||
|
||||
def __init__(self, request, *args, **kwargs):
|
||||
super(EditScriptForm, self).__init__(request, *args, **kwargs)
|
||||
self.order_fields()
|
||||
self.order_fields(self.fields_order)
|
||||
|
||||
class Meta(object):
|
||||
name = _("Upate Script")
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
# Copyright 2015 Objectif Libre
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
|
||||
class OrderFieldsMixin(object):
|
||||
|
||||
def order_fields(self):
|
||||
new_fields = OrderedDict()
|
||||
for field_name in self.fields_order:
|
||||
new_fields[field_name] = self.fields[field_name]
|
||||
self.fields = new_fields
|
Loading…
Reference in New Issue