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

« back to all changes in this revision

Viewing changes to openstack_dashboard/dashboards/admin/routers/tables.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-01-11 08:26:40 UTC
  • mto: (1.2.1) (70.1.1 utopic-proposed)
  • mto: This revision was merged to the branch mainline in revision 39.
  • Revision ID: package-import@ubuntu.com-20130111082640-mjx6r75udhhiajq3
Tags: upstream-2013.1~g2
ImportĀ upstreamĀ versionĀ 2013.1~g2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
3
# Copyright 2012,  Nachi Ueno,  NTT MCL,  Inc.
 
4
#
 
5
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
6
#    not use this file except in compliance with the License. You may obtain
 
7
#    a copy of the License at
 
8
#
 
9
#         http://www.apache.org/licenses/LICENSE-2.0
 
10
#
 
11
#    Unless required by applicable law or agreed to in writing, software
 
12
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
13
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
14
#    License for the specific language governing permissions and limitations
 
15
#    under the License.
 
16
 
 
17
import logging
 
18
 
 
19
from django.template.defaultfilters import title
 
20
from django.utils.translation import ugettext_lazy as _
 
21
 
 
22
from horizon import tables
 
23
from openstack_dashboard import api
 
24
from openstack_dashboard.dashboards.project.routers import tables as r_tables
 
25
 
 
26
 
 
27
LOG = logging.getLogger(__name__)
 
28
 
 
29
 
 
30
class DeleteRouter(r_tables.DeleteRouter):
 
31
    redirect_url = "horizon:admin:routers:index"
 
32
 
 
33
    def allowed(self, request, router=None):
 
34
        return True
 
35
 
 
36
 
 
37
class CreateRouter(tables.LinkAction):
 
38
    name = "create"
 
39
    verbose_name = _("Create Router")
 
40
    url = "horizon:admin:routers:create"
 
41
    classes = ("ajax-modal", "btn-create")
 
42
 
 
43
 
 
44
class UpdateRow(tables.Row):
 
45
    ajax = True
 
46
 
 
47
    def get_data(self, request, router_id):
 
48
        router = api.router_get(request, router_id)
 
49
        return router
 
50
 
 
51
 
 
52
class RoutersTable(tables.DataTable):
 
53
    tenant = tables.Column("tenant_name", verbose_name=_("Project"))
 
54
    name = tables.Column("name",
 
55
                         verbose_name=_("Name"),
 
56
                         link="horizon:admin:routers:detail")
 
57
    status = tables.Column("status",
 
58
                           filters=(title,),
 
59
                           verbose_name=_("Status"),
 
60
                           status=True)
 
61
 
 
62
    def get_object_display(self, obj):
 
63
        return obj.name
 
64
 
 
65
    class Meta:
 
66
        name = "Routers"
 
67
        verbose_name = _("Routers")
 
68
        status_columns = ["status"]
 
69
        row_class = UpdateRow
 
70
        table_actions = (CreateRouter, DeleteRouter)
 
71
        row_actions = (DeleteRouter, )