~ubuntu-branches/ubuntu/utopic/horizon/utopic-updates

« back to all changes in this revision

Viewing changes to openstack_dashboard/dashboards/project/networks/tables.py

  • Committer: Package Import Robot
  • Author(s): James Page, Chris Johnston, James Page
  • Date: 2014-10-03 17:54:18 UTC
  • mfrom: (0.4.1) (1.1.44) (70.1.2 utopic)
  • Revision ID: package-import@ubuntu.com-20141003175418-1jomx0azdvnl5fxz
Tags: 1:2014.2~rc1-0ubuntu1
[ Chris Johnston ]
* d/theme/css/ubuntu.css: Fix Ubuntu theme for Instances "more" dropdown
  (LP: #1308651).

[ James Page ]
* New upstream release candidate:
  - d/p/*: Refresh.
* d/watch: Use tarballs.openstack.org for upstream releases. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
from django import template
18
18
from django.template import defaultfilters as filters
19
19
from django.utils.translation import ugettext_lazy as _
 
20
from django.utils.translation import ungettext_lazy
20
21
 
21
22
from horizon import exceptions
22
23
from horizon import tables
23
24
 
24
25
from openstack_dashboard import api
25
 
 
 
26
from openstack_dashboard import policy
26
27
 
27
28
LOG = logging.getLogger(__name__)
28
29
 
37
38
        return True
38
39
 
39
40
 
40
 
class DeleteNetwork(CheckNetworkEditable, tables.DeleteAction):
41
 
    data_type_singular = _("Network")
42
 
    data_type_plural = _("Networks")
 
41
class DeleteNetwork(policy.PolicyTargetMixin, CheckNetworkEditable,
 
42
                    tables.DeleteAction):
 
43
    @staticmethod
 
44
    def action_present(count):
 
45
        return ungettext_lazy(
 
46
            u"Delete Network",
 
47
            u"Delete Networks",
 
48
            count
 
49
        )
 
50
 
 
51
    @staticmethod
 
52
    def action_past(count):
 
53
        return ungettext_lazy(
 
54
            u"Deleted Network",
 
55
            u"Deleted Networks",
 
56
            count
 
57
        )
 
58
 
43
59
    policy_rules = (("network", "delete_network"),)
44
60
 
45
 
    def get_policy_target(self, request, datum=None):
46
 
        project_id = None
47
 
        if datum:
48
 
            project_id = getattr(datum, 'tenant_id', None)
49
 
        return {"project_id": project_id}
50
 
 
51
61
    def delete(self, request, network_id):
52
62
        try:
53
63
            # Retrieve existing subnets belonging to the network.
76
86
    policy_rules = (("network", "create_network"),)
77
87
 
78
88
 
79
 
class EditNetwork(CheckNetworkEditable, tables.LinkAction):
 
89
class EditNetwork(policy.PolicyTargetMixin, CheckNetworkEditable,
 
90
                  tables.LinkAction):
80
91
    name = "update"
81
92
    verbose_name = _("Edit Network")
82
93
    url = "horizon:project:networks:update"
84
95
    icon = "pencil"
85
96
    policy_rules = (("network", "update_network"),)
86
97
 
87
 
    def get_policy_target(self, request, datum=None):
88
 
        project_id = None
89
 
        if datum:
90
 
            project_id = getattr(datum, 'tenant_id', None)
91
 
        return {"project_id": project_id}
92
 
 
93
 
 
94
 
class CreateSubnet(CheckNetworkEditable, tables.LinkAction):
 
98
 
 
99
class CreateSubnet(policy.PolicyTargetMixin, CheckNetworkEditable,
 
100
                   tables.LinkAction):
95
101
    name = "subnet"
96
102
    verbose_name = _("Add Subnet")
97
103
    url = "horizon:project:networks:addsubnet"
98
104
    classes = ("ajax-modal",)
99
105
    icon = "plus"
100
106
    policy_rules = (("network", "create_subnet"),)
101
 
 
102
 
    def get_policy_target(self, request, datum=None):
103
 
        project_id = None
104
 
        if datum:
105
 
            project_id = getattr(datum, 'tenant_id', None)
106
 
        return {"network:project_id": project_id}
 
107
    policy_target_attrs = (("network:project_id", "tenant_id"),)
107
108
 
108
109
 
109
110
def get_subnets(network):