diff --git a/openstack_dashboard/dashboards/admin/instances/tables.py b/openstack_dashboard/dashboards/admin/instances/tables.py index 8347d4796a..8b7a417b5a 100644 --- a/openstack_dashboard/dashboards/admin/instances/tables.py +++ b/openstack_dashboard/dashboards/admin/instances/tables.py @@ -15,6 +15,7 @@ from django.template.defaultfilters import title # noqa from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ungettext_lazy from horizon import tables from horizon.utils import filters @@ -31,13 +32,25 @@ class AdminEditInstance(project_tables.EditInstance): class MigrateInstance(policy.PolicyTargetMixin, tables.BatchAction): name = "migrate" - action_present = _("Migrate") - action_past = _("Scheduled migration (pending confirmation) of") - data_type_singular = _("Instance") - data_type_plural = _("Instances") classes = ("btn-migrate", "btn-danger") policy_rules = (("compute", "compute_extension:admin_actions:migrate"),) + @staticmethod + def action_present(count): + return ungettext_lazy( + u"Migrate Instance", + u"Migrate Instances", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + u"Scheduled migration (pending confirmation) of Instance", + u"Scheduled migration (pending confirmation) of Instances", + count + ) + def allowed(self, request, instance): return ((instance.status in project_tables.ACTIVE_STATES or instance.status == 'SHUTOFF') diff --git a/openstack_dashboard/dashboards/project/loadbalancers/tables.py b/openstack_dashboard/dashboards/project/loadbalancers/tables.py index 99ec7e7783..718d58e0ae 100644 --- a/openstack_dashboard/dashboards/project/loadbalancers/tables.py +++ b/openstack_dashboard/dashboards/project/loadbalancers/tables.py @@ -17,6 +17,7 @@ from django.core.urlresolvers import reverse from django.template import defaultfilters as filters from django.utils import http from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ungettext_lazy from horizon import exceptions from horizon import tables @@ -72,12 +73,24 @@ class AddMonitorLink(tables.LinkAction): class DeleteVipLink(policy.PolicyTargetMixin, tables.DeleteAction): name = "deletevip" - action_present = _("Delete") - action_past = _("Scheduled deletion of %(data_type)s") - data_type_singular = _("VIP") - data_type_plural = _("VIPs") policy_rules = (("network", "delete_vip"),) + @staticmethod + def action_present(count): + return ungettext_lazy( + u"Delete VIP", + u"Delete VIPs", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + u"Scheduled deletion of VIP", + u"Scheduled deletion of VIPs", + count + ) + def allowed(self, request, datum=None): if datum and not datum.vip_id: return False @@ -86,12 +99,24 @@ class DeleteVipLink(policy.PolicyTargetMixin, tables.DeleteAction): class DeletePoolLink(policy.PolicyTargetMixin, tables.DeleteAction): name = "deletepool" - action_present = _("Delete") - action_past = _("Scheduled deletion of %(data_type)s") - data_type_singular = _("Pool") - data_type_plural = _("Pools") policy_rules = (("network", "delete_pool"),) + @staticmethod + def action_present(count): + return ungettext_lazy( + u"Delete Pool", + u"Delete Pools", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + u"Scheduled deletion of Pool", + u"Scheduled deletion of Pools", + count + ) + def allowed(self, request, datum=None): if datum and datum.vip_id: return False @@ -101,21 +126,45 @@ class DeletePoolLink(policy.PolicyTargetMixin, tables.DeleteAction): class DeleteMonitorLink(policy.PolicyTargetMixin, tables.DeleteAction): name = "deletemonitor" - action_present = _("Delete") - action_past = _("Scheduled deletion of %(data_type)s") - data_type_singular = _("Monitor") - data_type_plural = _("Monitors") policy_rules = (("network", "delete_health_monitor"),) + @staticmethod + def action_present(count): + return ungettext_lazy( + u"Delete Monitor", + u"Delete Monitors", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + u"Scheduled deletion of Monitor", + u"Scheduled deletion of Monitors", + count + ) + class DeleteMemberLink(policy.PolicyTargetMixin, tables.DeleteAction): name = "deletemember" - action_present = _("Delete") - action_past = _("Scheduled deletion of %(data_type)s") - data_type_singular = _("Member") - data_type_plural = _("Members") policy_rules = (("network", "delete_member"),) + @staticmethod + def action_present(count): + return ungettext_lazy( + u"Delete Member", + u"Delete Members", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + u"Scheduled deletion of Member", + u"Scheduled deletion of Members", + count + ) + class UpdatePoolLink(policy.PolicyTargetMixin, tables.LinkAction): name = "updatepool" diff --git a/openstack_dashboard/dashboards/project/volumes/volumes/tables.py b/openstack_dashboard/dashboards/project/volumes/volumes/tables.py index f3dbf9e639..43f0bba406 100644 --- a/openstack_dashboard/dashboards/project/volumes/volumes/tables.py +++ b/openstack_dashboard/dashboards/project/volumes/volumes/tables.py @@ -379,13 +379,26 @@ class VolumesTable(VolumesTableBase): class DetachVolume(tables.BatchAction): name = "detach" - action_present = _("Detach") - action_past = _("Detaching") # This action is asynchronous. - data_type_singular = _("Volume") - data_type_plural = _("Volumes") classes = ('btn-danger', 'btn-detach') policy_rules = (("compute", "compute:detach_volume"),) + @staticmethod + def action_present(count): + return ungettext_lazy( + u"Detach Volume", + u"Detach Volumes", + count + ) + + # This action is asynchronous. + @staticmethod + def action_past(count): + return ungettext_lazy( + u"Detaching Volume", + u"Detaching Volumes", + count + ) + def action(self, request, obj_id): attachment = self.table.get_object_by_id(obj_id) api.nova.instance_volume_detach(request, diff --git a/openstack_dashboard/dashboards/project/vpn/tables.py b/openstack_dashboard/dashboards/project/vpn/tables.py index be59f8d655..c64c5dac66 100644 --- a/openstack_dashboard/dashboards/project/vpn/tables.py +++ b/openstack_dashboard/dashboards/project/vpn/tables.py @@ -18,6 +18,7 @@ from django.core.urlresolvers import reverse from django.template.defaultfilters import title # noqa from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ungettext_lazy from horizon import tables from horizon.utils import filters @@ -64,12 +65,24 @@ class AddIPSecSiteConnectionLink(tables.LinkAction): class DeleteVPNServiceLink(tables.DeleteAction): name = "deletevpnservice" - action_present = _("Delete") - action_past = _("Scheduled deletion of %(data_type)s") - data_type_singular = _("VPN Service") - data_type_plural = _("VPN Services") policy_rules = (("network", "delete_vpnservice"),) + @staticmethod + def action_present(count): + return ungettext_lazy( + u"Delete VPN Service", + u"Delete VPN Services", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + u"Scheduled deletion of VPN Service", + u"Scheduled deletion of VPN Services", + count + ) + def allowed(self, request, datum=None): if datum and datum.ipsecsiteconns: return False @@ -78,12 +91,24 @@ class DeleteVPNServiceLink(tables.DeleteAction): class DeleteIKEPolicyLink(tables.DeleteAction): name = "deleteikepolicy" - action_present = _("Delete") - action_past = _("Scheduled deletion of %(data_type)s") - data_type_singular = _("IKE Policy") - data_type_plural = _("IKE Policies") policy_rules = (("network", "delete_ikepolicy"),) + @staticmethod + def action_present(count): + return ungettext_lazy( + u"Delete IKE Policy", + u"Delete IKE Policies", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + u"Scheduled deletion of IKE Policy", + u"Scheduled deletion of IKE Policies", + count + ) + def allowed(self, request, datum=None): if datum and datum.ipsecsiteconns: return False @@ -92,12 +117,24 @@ class DeleteIKEPolicyLink(tables.DeleteAction): class DeleteIPSecPolicyLink(tables.DeleteAction): name = "deleteipsecpolicy" - action_present = _("Delete") - action_past = _("Scheduled deletion of %(data_type)s") - data_type_singular = _("IPSec Policy") - data_type_plural = _("IPSec Policies") policy_rules = (("network", "delete_ipsecpolicy"),) + @staticmethod + def action_present(count): + return ungettext_lazy( + u"Delete IPSec Policy", + u"Delete IPSec Policies", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + u"Scheduled deletion of IPSec Policy", + u"Scheduled deletion of IPSec Policies", + count + ) + def allowed(self, request, datum=None): if datum and datum.ipsecsiteconns: return False @@ -106,12 +143,24 @@ class DeleteIPSecPolicyLink(tables.DeleteAction): class DeleteIPSecSiteConnectionLink(tables.DeleteAction): name = "deleteipsecsiteconnection" - action_present = _("Delete") - action_past = _("Scheduled deletion of %(data_type)s") - data_type_singular = _("IPSec Site Connection") - data_type_plural = _("IPSec Site Connections") policy_rules = (("network", "delete_ipsec_site_connection"),) + @staticmethod + def action_present(count): + return ungettext_lazy( + u"Delete IPSec Site Connection", + u"Delete IPSec Site Connections", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + u"Scheduled deletion of IPSec Site Connection", + u"Scheduled deletion of IPSec Site Connections", + count + ) + class UpdateVPNServiceLink(tables.LinkAction): name = "update_vpnservice"