~ubuntu-branches/ubuntu/raring/horizon/raring

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 08:49:14 UTC
  • mfrom: (1.1.22)
  • Revision ID: package-import@ubuntu.com-20121123084914-95m0mzmiicdw64ti
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/patches/add_juju_settings_pannel.patch: Disable during
  Grizzly dev. cycle. 

[ Chuck Short ]
* New upstream relase.
* Refreshed patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import logging
2
 
 
3
 
from django.utils.translation import ugettext_lazy as _
4
 
 
5
 
from horizon import api
6
 
from horizon import tables
7
 
 
8
 
 
9
 
LOG = logging.getLogger(__name__)
10
 
 
11
 
 
12
 
class DeleteFlavor(tables.DeleteAction):
13
 
    data_type_singular = _("Flavor")
14
 
    data_type_plural = _("Flavors")
15
 
 
16
 
    def delete(self, request, obj_id):
17
 
        api.flavor_delete(request, obj_id)
18
 
 
19
 
 
20
 
class CreateFlavor(tables.LinkAction):
21
 
    name = "create"
22
 
    verbose_name = _("Create Flavor")
23
 
    url = "horizon:syspanel:flavors:create"
24
 
    classes = ("ajax-modal", "btn-create")
25
 
 
26
 
 
27
 
class EditFlavor(tables.LinkAction):
28
 
    name = "edit"
29
 
    verbose_name = _("Edit Flavor")
30
 
    url = "horizon:syspanel:flavors:edit"
31
 
    classes = ("ajax-modal", "btn-edit")
32
 
 
33
 
 
34
 
def get_size(flavor):
35
 
    return _("%sMB") % flavor.ram
36
 
 
37
 
 
38
 
class FlavorsTable(tables.DataTable):
39
 
    name = tables.Column('name', verbose_name=_('Flavor Name'))
40
 
    vcpus = tables.Column('vcpus', verbose_name=_('VCPUs'))
41
 
    ram = tables.Column(get_size,
42
 
                        verbose_name=_('RAM'),
43
 
                        attrs={'data-type': 'size'})
44
 
    disk = tables.Column('disk', verbose_name=_('Root Disk'))
45
 
    ephemeral = tables.Column('OS-FLV-EXT-DATA:ephemeral',
46
 
                              verbose_name=_('Ephemeral Disk'))
47
 
    flavor_id = tables.Column('id', verbose_name=('ID'))
48
 
 
49
 
    class Meta:
50
 
        name = "flavors"
51
 
        verbose_name = _("Flavors")
52
 
        table_actions = (CreateFlavor, DeleteFlavor)
53
 
        row_actions = (EditFlavor, DeleteFlavor)