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
This commit is contained in:
Guillaume Espanel 2015-07-29 13:35:17 +00:00 committed by Gauvain Pocentek
parent 3c577b0034
commit 4782d27932
4 changed files with 26 additions and 9 deletions

View File

@ -62,11 +62,15 @@ class ServicesTable(tables.DataTable):
class CreateGroup(tables.LinkAction): class CreateGroup(tables.LinkAction):
name = "creategroup" name = "creategroup"
verbose_name = _("Create new Group") verbose_name = _("Create new Group")
url = 'horizon:admin:hashmap:group_create'
icon = "create" icon = "create"
ajax = True ajax = True
classes = ("ajax-modal",) 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): class DeleteGroup(tables.BatchAction):
name = "deletegroup" name = "deletegroup"
@ -416,7 +420,7 @@ class FieldMappingsTab(tabs.TableTab):
class MappingsTab(tabs.TableTab): class MappingsTab(tabs.TableTab):
name = _("Mappings") name = _("Service Mappings")
slug = "hashmap_mappings" slug = "hashmap_mappings"
table_classes = (ServiceMappingsTable,) table_classes = (ServiceMappingsTable,)
template_name = "horizon/common/_detail_table.html" template_name = "horizon/common/_detail_table.html"
@ -432,11 +436,11 @@ class MappingsTab(tabs.TableTab):
class FieldTabs(tabs.TabGroup): class FieldTabs(tabs.TabGroup):
slug = "field_tabs" slug = "field_tabs"
tabs = (FieldThresholdsTab, FieldMappingsTab) tabs = (FieldMappingsTab, FieldThresholdsTab)
sticky = True sticky = True
class ServiceTabs(tabs.TabGroup): class ServiceTabs(tabs.TabGroup):
slug = "services_tabs" slug = "services_tabs"
tabs = (FieldsTab, MappingsTab, GroupsTab, ServiceThresholdsTab) tabs = (FieldsTab, MappingsTab, ServiceThresholdsTab, GroupsTab)
sticky = True sticky = True

View File

@ -41,7 +41,7 @@ urlpatterns = patterns(
url(r'^create_field/service/(?P<service_id>[^/]+)/?$', url(r'^create_field/service/(?P<service_id>[^/]+)/?$',
views.FieldCreateView.as_view(), views.FieldCreateView.as_view(),
name='field_create'), name='field_create'),
url(r'^create_group/?$', url(r'^create_group/(?P<service_id>[^/]+)/?$',
views.GroupCreateView.as_view(), views.GroupCreateView.as_view(),
name='group_create'), name='group_create'),
url(r'^create_threshold/service/(?P<service_id>[^/]+)/?$', url(r'^create_threshold/service/(?P<service_id>[^/]+)/?$',

View File

@ -191,12 +191,23 @@ class FieldMappingEditView(FieldMappingCreateView):
class GroupCreateView(forms.ModalFormView): class GroupCreateView(forms.ModalFormView):
form_class = hashmap_forms.CreateGroupForm form_class = hashmap_forms.CreateGroupForm
template_name = 'horizon/common/modal_form.html' template_name = 'horizon/common/modal_form.html'
success_url = reverse_lazy('horizon:admin:hashmap:index') submit_url = 'horizon:admin:hashmap:group_create'
submit_url = reverse_lazy('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): def get_object_id(self, obj):
return obj.group_id 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): def get_success_url(self, **kwargs):
return reverse('horizon:admin:hashmap:group', return reverse('horizon:admin:hashmap:group',

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import decimal
import json import json
from django import http from django import http
@ -39,8 +40,9 @@ def quote(request):
if request.method == 'POST': if request.method == 'POST':
json_data = json.loads(request.body) json_data = json.loads(request.body)
try: try:
pricing = (api.cloudkittyclient(request) pricing = decimal.Decimal(api.cloudkittyclient(request)
.quotations.quote(json_data)) .quotations.quote(json_data))
pricing = pricing.normalize().to_eng_string()
except Exception: except Exception:
exceptions.handle(request, exceptions.handle(request,
_('Unable to retrieve price.')) _('Unable to retrieve price.'))