diff --git a/cloudkittydashboard/dashboards/admin/hashmap/forms.py b/cloudkittydashboard/dashboards/admin/hashmap/forms.py index e9d3234..8521eb9 100644 --- a/cloudkittydashboard/dashboards/admin/hashmap/forms.py +++ b/cloudkittydashboard/dashboards/admin/hashmap/forms.py @@ -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] diff --git a/cloudkittydashboard/dashboards/admin/pyscripts/forms.py b/cloudkittydashboard/dashboards/admin/pyscripts/forms.py index df30b04..2f076f1 100644 --- a/cloudkittydashboard/dashboards/admin/pyscripts/forms.py +++ b/cloudkittydashboard/dashboards/admin/pyscripts/forms.py @@ -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") diff --git a/cloudkittydashboard/dashboards/common.py b/cloudkittydashboard/dashboards/common.py deleted file mode 100644 index 8249963..0000000 --- a/cloudkittydashboard/dashboards/common.py +++ /dev/null @@ -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