~ubuntu-branches/ubuntu/precise/horizon/precise-updates

« back to all changes in this revision

Viewing changes to horizon/horizon/dashboards/syspanel/projects/tables.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-03-02 12:11:59 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20120302121159-65b88lcl4slve26i
Tags: 2012.1~e4-0ubuntu1
* New upstream version.
* debian/rules: Update due to upstream build changes.
* debian/control: Update standards-version.
* debian/patches/openstack-config-settings.patch: Dropped
* debian/patches/fix-dashboard-django-wsgi.patch: Refreshed
* debian/patches/fix-dashboard-manage.patch: Refreshed
* debian/openstack-dashboard.install: Update due to upstream build changes.
* debian/dashboard: Update to upstream build changes.
* debian/pydist-overrides: Dont try to install python-django-nose-selenium.
* debian/openstack-dashboard.install: Add missing config files.
* debian/rules: Fix broken settings.py
* debian/patches/pkg-setup.patch: Copy missing templates, shameously
  taken from debian
* debian/patches/fix-broken-tarbll.patch: Add missing files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import logging
2
 
 
3
 
from django.core.urlresolvers import reverse
4
 
from django.utils.translation import ugettext_lazy as _
5
 
 
6
 
from horizon import api
7
 
from horizon import tables
8
 
 
9
 
from ..users.tables import UsersTable
10
 
 
11
 
 
12
 
LOG = logging.getLogger(__name__)
13
 
 
14
 
 
15
 
class ModifyQuotasLink(tables.LinkAction):
16
 
    name = "quotas"
17
 
    verbose_name = _("Modify Quotas")
18
 
    url = "horizon:syspanel:projects:quotas"
19
 
    attrs = {"class": "ajax-modal"}
20
 
 
21
 
 
22
 
class ViewMembersLink(tables.LinkAction):
23
 
    name = "users"
24
 
    verbose_name = _("Modify Users")
25
 
    url = "horizon:syspanel:projects:users"
26
 
 
27
 
 
28
 
class UsageLink(tables.LinkAction):
29
 
    name = "usage"
30
 
    verbose_name = _("View Usage")
31
 
    url = "horizon:syspanel:projects:usage"
32
 
 
33
 
 
34
 
class EditLink(tables.LinkAction):
35
 
    name = "update"
36
 
    verbose_name = _("Edit Project")
37
 
    url = "horizon:syspanel:projects:update"
38
 
    attrs = {"class": "ajax-modal"}
39
 
 
40
 
 
41
 
class CreateLink(tables.LinkAction):
42
 
    name = "create"
43
 
    verbose_name = _("Create New Project")
44
 
    url = "horizon:syspanel:projects:create"
45
 
    classes = ("ajax-modal",)
46
 
 
47
 
 
48
 
class DeleteTenantsAction(tables.DeleteAction):
49
 
    data_type_singular = _("Project")
50
 
    data_type_plural = _("Projects")
51
 
 
52
 
    def delete(self, request, obj_id):
53
 
        api.keystone.tenant_delete(request, obj_id)
54
 
 
55
 
 
56
 
class TenantFilterAction(tables.FilterAction):
57
 
    def filter(self, table, tenants, filter_string):
58
 
        """ Really naive case-insensitive search. """
59
 
        # FIXME(gabriel): This should be smarter. Written for demo purposes.
60
 
        q = filter_string.lower()
61
 
 
62
 
        def comp(tenant):
63
 
            if q in tenant.name.lower():
64
 
                return True
65
 
            return False
66
 
 
67
 
        return filter(comp, tenants)
68
 
 
69
 
 
70
 
class TenantsTable(tables.DataTable):
71
 
    id = tables.Column('id', verbose_name=_('Id'))
72
 
    name = tables.Column('name', verbose_name=_('Name'))
73
 
    description = tables.Column(lambda obj: getattr(obj, 'description', None),
74
 
                                verbose_name=_('Description'))
75
 
    enabled = tables.Column('enabled', verbose_name=_('Enabled'), status=True)
76
 
 
77
 
    class Meta:
78
 
        name = "tenants"
79
 
        verbose_name = _("Projects")
80
 
        row_actions = (EditLink, UsageLink, ViewMembersLink, ModifyQuotasLink,
81
 
                       DeleteTenantsAction)
82
 
        table_actions = (TenantFilterAction, CreateLink, DeleteTenantsAction)
83
 
 
84
 
 
85
 
class RemoveUserAction(tables.BatchAction):
86
 
    name = "remove_user"
87
 
    action_present = _("Remove")
88
 
    action_past = _("Removed")
89
 
    data_type_singular = _("User")
90
 
    data_type_plural = _("Users")
91
 
    classes = ('btn-danger',)
92
 
 
93
 
    def action(self, request, user_id):
94
 
        tenant_id = self.table.kwargs['tenant_id']
95
 
        api.keystone.remove_tenant_user(request, tenant_id, user_id)
96
 
 
97
 
 
98
 
class TenantUsersTable(UsersTable):
99
 
    class Meta:
100
 
        name = "tenant_users"
101
 
        verbose_name = _("Users For Project")
102
 
        table_actions = (RemoveUserAction,)
103
 
        row_actions = (RemoveUserAction,)
104
 
 
105
 
 
106
 
class AddUserAction(tables.LinkAction):
107
 
    name = "add_user"
108
 
    verbose_name = _("Add To Project")
109
 
    url = "horizon:syspanel:projects:add_user"
110
 
    classes = ('ajax-modal',)
111
 
 
112
 
    def get_link_url(self, user):
113
 
        tenant_id = self.table.kwargs['tenant_id']
114
 
        return reverse(self.url, args=(tenant_id, user.id))
115
 
 
116
 
 
117
 
class AddUsersTable(UsersTable):
118
 
    class Meta:
119
 
        name = "add_users"
120
 
        verbose_name = _("Add New Users")
121
 
        table_actions = ()
122
 
        row_actions = (AddUserAction,)