From 827e5a36fabee65bba739da66dacb7388d604f5d Mon Sep 17 00:00:00 2001 From: Doug Fish Date: Thu, 25 Sep 2014 13:08:01 -0500 Subject: [PATCH] Fix concatenation in Network and Router actions Remove concatenation and pluralization issues from Delete Network, Delete Subnet, Delete Router Rule, Clear Gateway, and Delete Network Profile Change-Id: I0898b446abd79672b43b55be62dba6250a4fdd58 partial-bug: 1307476 --- .../project/networks/subnets/tables.py | 19 ++++++++++++++++-- .../dashboards/project/networks/tables.py | 19 ++++++++++++++++-- .../routers/extensions/routerrules/tables.py | 19 ++++++++++++++++-- .../dashboards/project/routers/tables.py | 20 +++++++++++++++---- .../dashboards/router/nexus1000v/tables.py | 18 +++++++++++++++-- 5 files changed, 83 insertions(+), 12 deletions(-) diff --git a/openstack_dashboard/dashboards/project/networks/subnets/tables.py b/openstack_dashboard/dashboards/project/networks/subnets/tables.py index 6712d23d83..4214970c31 100644 --- a/openstack_dashboard/dashboards/project/networks/subnets/tables.py +++ b/openstack_dashboard/dashboards/project/networks/subnets/tables.py @@ -17,6 +17,7 @@ import logging from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse_lazy from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ungettext_lazy from horizon import exceptions from horizon import tables @@ -43,8 +44,22 @@ class CheckNetworkEditable(object): class DeleteSubnet(policy.PolicyTargetMixin, CheckNetworkEditable, tables.DeleteAction): - data_type_singular = _("Subnet") - data_type_plural = _("Subnets") + @staticmethod + def action_present(count): + return ungettext_lazy( + u"Delete Subnet", + u"Delete Subnets", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + u"Deleted Subnet", + u"Deleted Subnets", + count + ) + policy_rules = (("network", "delete_subnet"),) policy_target_attrs = (("network:project_id", "tenant_id"),) diff --git a/openstack_dashboard/dashboards/project/networks/tables.py b/openstack_dashboard/dashboards/project/networks/tables.py index fcd662a2f5..9fadab87e4 100644 --- a/openstack_dashboard/dashboards/project/networks/tables.py +++ b/openstack_dashboard/dashboards/project/networks/tables.py @@ -17,6 +17,7 @@ from django.core.urlresolvers import reverse from django import template from django.template import defaultfilters as filters from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ungettext_lazy from horizon import exceptions from horizon import tables @@ -39,8 +40,22 @@ class CheckNetworkEditable(object): class DeleteNetwork(policy.PolicyTargetMixin, CheckNetworkEditable, tables.DeleteAction): - data_type_singular = _("Network") - data_type_plural = _("Networks") + @staticmethod + def action_present(count): + return ungettext_lazy( + u"Delete Network", + u"Delete Networks", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + u"Deleted Network", + u"Deleted Networks", + count + ) + policy_rules = (("network", "delete_network"),) def delete(self, request, network_id): diff --git a/openstack_dashboard/dashboards/project/routers/extensions/routerrules/tables.py b/openstack_dashboard/dashboards/project/routers/extensions/routerrules/tables.py index bf29e57a86..8d89de23de 100644 --- a/openstack_dashboard/dashboards/project/routers/extensions/routerrules/tables.py +++ b/openstack_dashboard/dashboards/project/routers/extensions/routerrules/tables.py @@ -16,6 +16,7 @@ import logging from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ungettext_lazy from openstack_dashboard.dashboards.project.routers.extensions.routerrules\ import rulemanager @@ -40,8 +41,22 @@ class AddRouterRule(policy.PolicyTargetMixin, tables.LinkAction): class RemoveRouterRule(policy.PolicyTargetMixin, tables.DeleteAction): - data_type_singular = _("Router Rule") - data_type_plural = _("Router Rules") + @staticmethod + def action_present(count): + return ungettext_lazy( + u"Delete Router Rule", + u"Delete Router Rules", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + u"Deleted Router Rule", + u"Deleted Router Rules", + count + ) + failure_url = 'horizon:project:routers:detail' policy_rules = (("network", "update_router"),) diff --git a/openstack_dashboard/dashboards/project/routers/tables.py b/openstack_dashboard/dashboards/project/routers/tables.py index 7924f06001..38064da481 100644 --- a/openstack_dashboard/dashboards/project/routers/tables.py +++ b/openstack_dashboard/dashboards/project/routers/tables.py @@ -102,11 +102,23 @@ class SetGateway(policy.PolicyTargetMixin, tables.LinkAction): class ClearGateway(policy.PolicyTargetMixin, tables.BatchAction): + @staticmethod + def action_present(count): + return ungettext_lazy( + u"Clear Gateway", + u"Clear Gateways", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + u"Cleared Gateway", + u"Cleared Gateways", + count + ) + name = "cleargateway" - action_present = _("Clear") - action_past = _("Cleared") - data_type_singular = _("Gateway") - data_type_plural = _("Gateways") classes = ('btn-danger', 'btn-cleargateway') redirect_url = "horizon:project:routers:index" policy_rules = (("network", "update_router"),) diff --git a/openstack_dashboard/dashboards/router/nexus1000v/tables.py b/openstack_dashboard/dashboards/router/nexus1000v/tables.py index e1183c1eff..e2f0ea60a2 100644 --- a/openstack_dashboard/dashboards/router/nexus1000v/tables.py +++ b/openstack_dashboard/dashboards/router/nexus1000v/tables.py @@ -17,6 +17,7 @@ import logging from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ungettext_lazy from horizon import exceptions from horizon import tables @@ -35,8 +36,21 @@ class CreateNetworkProfile(tables.LinkAction): class DeleteNetworkProfile(tables.DeleteAction): - data_type_singular = _("Network Profile") - data_type_plural = _("Network Profiles") + @staticmethod + def action_present(count): + return ungettext_lazy( + u"Delete Network Profile", + u"Delete Network Profiles", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + u"Deleted Network Profile", + u"Deleted Network Profiles", + count + ) def delete(self, request, obj_id): try: