From 4782d27932b414eddbaebdbbebc9742bd9afafe3 Mon Sep 17 00:00:00 2001 From: Guillaume Espanel Date: Wed, 29 Jul 2015 13:35:17 +0000 Subject: [PATCH] Address some cosmetic issues on the dashboard - Redirect to the service page after creating a group - Strip trailing 0s from the quote price in instance creation modal - Harmonize panels order in the hashmap dashboard Change-Id: Ib18608da0a95f8e17f9eecf28a032d6f1bae4ea3 --- .../dashboards/admin/hashmap/tables.py | 12 ++++++++---- .../dashboards/admin/hashmap/urls.py | 2 +- .../dashboards/admin/hashmap/views.py | 15 +++++++++++++-- .../dashboards/project/rating/views.py | 6 ++++-- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/cloudkittydashboard/dashboards/admin/hashmap/tables.py b/cloudkittydashboard/dashboards/admin/hashmap/tables.py index 7aa35dd..8bd7b45 100644 --- a/cloudkittydashboard/dashboards/admin/hashmap/tables.py +++ b/cloudkittydashboard/dashboards/admin/hashmap/tables.py @@ -62,11 +62,15 @@ class ServicesTable(tables.DataTable): class CreateGroup(tables.LinkAction): name = "creategroup" verbose_name = _("Create new Group") - url = 'horizon:admin:hashmap:group_create' icon = "create" ajax = True classes = ("ajax-modal",) + def get_link_url(self, datum=None): + url = 'horizon:admin:hashmap:group_create' + service_id = self.table.request.service_id + return reverse(url, args=[service_id]) + class DeleteGroup(tables.BatchAction): name = "deletegroup" @@ -416,7 +420,7 @@ class FieldMappingsTab(tabs.TableTab): class MappingsTab(tabs.TableTab): - name = _("Mappings") + name = _("Service Mappings") slug = "hashmap_mappings" table_classes = (ServiceMappingsTable,) template_name = "horizon/common/_detail_table.html" @@ -432,11 +436,11 @@ class MappingsTab(tabs.TableTab): class FieldTabs(tabs.TabGroup): slug = "field_tabs" - tabs = (FieldThresholdsTab, FieldMappingsTab) + tabs = (FieldMappingsTab, FieldThresholdsTab) sticky = True class ServiceTabs(tabs.TabGroup): slug = "services_tabs" - tabs = (FieldsTab, MappingsTab, GroupsTab, ServiceThresholdsTab) + tabs = (FieldsTab, MappingsTab, ServiceThresholdsTab, GroupsTab) sticky = True diff --git a/cloudkittydashboard/dashboards/admin/hashmap/urls.py b/cloudkittydashboard/dashboards/admin/hashmap/urls.py index 732636c..95b4106 100644 --- a/cloudkittydashboard/dashboards/admin/hashmap/urls.py +++ b/cloudkittydashboard/dashboards/admin/hashmap/urls.py @@ -41,7 +41,7 @@ urlpatterns = patterns( url(r'^create_field/service/(?P[^/]+)/?$', views.FieldCreateView.as_view(), name='field_create'), - url(r'^create_group/?$', + url(r'^create_group/(?P[^/]+)/?$', views.GroupCreateView.as_view(), name='group_create'), url(r'^create_threshold/service/(?P[^/]+)/?$', diff --git a/cloudkittydashboard/dashboards/admin/hashmap/views.py b/cloudkittydashboard/dashboards/admin/hashmap/views.py index 27a8f0d..672b0ab 100644 --- a/cloudkittydashboard/dashboards/admin/hashmap/views.py +++ b/cloudkittydashboard/dashboards/admin/hashmap/views.py @@ -191,12 +191,23 @@ class FieldMappingEditView(FieldMappingCreateView): class GroupCreateView(forms.ModalFormView): form_class = hashmap_forms.CreateGroupForm template_name = 'horizon/common/modal_form.html' - success_url = reverse_lazy('horizon:admin:hashmap:index') - submit_url = reverse_lazy('horizon:admin:hashmap:group_create') + submit_url = 'horizon:admin:hashmap:group_create' + + def get_success_url(self, **kwargs): + return reverse('horizon:admin:hashmap:service', + args=(self.kwargs['service_id'],)) def get_object_id(self, obj): return obj.group_id + def get_context_data(self, **kwargs): + context = super(GroupCreateView, + self).get_context_data(**kwargs) + context["service_id"] = self.kwargs.get('service_id') + context['submit_url'] = reverse_lazy(self.submit_url, + args=(context['service_id'], )) + return context + ''' def get_success_url(self, **kwargs): return reverse('horizon:admin:hashmap:group', diff --git a/cloudkittydashboard/dashboards/project/rating/views.py b/cloudkittydashboard/dashboards/project/rating/views.py index 5b95f83..f3c730c 100644 --- a/cloudkittydashboard/dashboards/project/rating/views.py +++ b/cloudkittydashboard/dashboards/project/rating/views.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +import decimal import json from django import http @@ -39,8 +40,9 @@ def quote(request): if request.method == 'POST': json_data = json.loads(request.body) try: - pricing = (api.cloudkittyclient(request) - .quotations.quote(json_data)) + pricing = decimal.Decimal(api.cloudkittyclient(request) + .quotations.quote(json_data)) + pricing = pricing.normalize().to_eng_string() except Exception: exceptions.handle(request, _('Unable to retrieve price.'))