~ubuntu-branches/ubuntu/trusty/horizon/trusty-updates

« back to all changes in this revision

Viewing changes to openstack_dashboard/dashboards/project/images_and_snapshots/views.py

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman
  • Date: 2013-09-06 11:59:43 UTC
  • mfrom: (1.1.30)
  • Revision ID: package-import@ubuntu.com-20130906115943-h3td0l7tp16mb9oc
Tags: 1:2013.2~b3-0ubuntu1
* New upstream release.
* debian/control: Minimum python-openstack-auth version >= 1.1.1.
* debian/control: Add python-troveclient.
* debian/static: Refresh static assets for 2013.2~b3.
* debian/patches: ubuntu_local_settings.patch -> ubuntu_settings.patch, also
  patch location of secret key in openstack_dashboard/settings.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
import logging
27
27
 
28
 
from django.utils.translation import ugettext_lazy as _
 
28
from django.utils.translation import ugettext_lazy as _  # noqa
29
29
 
30
30
from horizon import exceptions
31
31
from horizon import tables
32
32
from horizon import tabs
33
33
 
34
34
from openstack_dashboard import api
35
 
from openstack_dashboard.api.base import is_service_enabled
 
35
from openstack_dashboard.api import base
36
36
 
37
 
from openstack_dashboard.dashboards.project.images_and_snapshots.\
38
 
    images.tables import ImagesTable
39
 
from openstack_dashboard.dashboards.project.images_and_snapshots.\
40
 
    volume_snapshots.tables import VolumeSnapshotsTable
41
 
from openstack_dashboard.dashboards.project.images_and_snapshots.\
42
 
    volume_snapshots.tabs import SnapshotDetailTabs
 
37
from openstack_dashboard.dashboards.project.images_and_snapshots.images \
 
38
    import tables as images_tables
 
39
from openstack_dashboard.dashboards.project.images_and_snapshots.\
 
40
    volume_snapshots import tables as vol_snsh_tables
 
41
from openstack_dashboard.dashboards.project.images_and_snapshots.\
 
42
    volume_snapshots import tabs as vol_snsh_tabs
43
43
 
44
44
LOG = logging.getLogger(__name__)
45
45
 
46
46
 
47
47
class IndexView(tables.MultiTableView):
48
 
    table_classes = (ImagesTable, VolumeSnapshotsTable)
 
48
    table_classes = (images_tables.ImagesTable,
 
49
                     vol_snsh_tables.VolumeSnapshotsTable)
49
50
    template_name = 'project/images_and_snapshots/index.html'
50
51
 
51
52
    def has_more_data(self, table):
52
53
        return getattr(self, "_more_%s" % table.name, False)
53
54
 
54
55
    def get_images_data(self):
55
 
        marker = self.request.GET.get(ImagesTable._meta.pagination_param, None)
 
56
        marker = self.request.GET.get(
 
57
            images_tables.ImagesTable._meta.pagination_param, None)
56
58
        try:
57
59
            # FIXME(gabriel): The paging is going to be strange here due to
58
60
            # our filtering after the fact.
61
63
                                                                 marker=marker)
62
64
            images = [im for im in all_images
63
65
                      if im.container_format not in ['aki', 'ari']]
64
 
        except:
 
66
        except Exception:
65
67
            images = []
66
68
            exceptions.handle(self.request, _("Unable to retrieve images."))
67
69
        return images
68
70
 
69
71
    def get_volume_snapshots_data(self):
70
 
        if is_service_enabled(self.request, 'volume'):
 
72
        if base.is_service_enabled(self.request, 'volume'):
71
73
            try:
72
74
                snapshots = api.cinder.volume_snapshot_list(self.request)
73
 
            except:
 
75
            except Exception:
74
76
                snapshots = []
75
77
                exceptions.handle(self.request, _("Unable to retrieve "
76
78
                                                  "volume snapshots."))
80
82
 
81
83
 
82
84
class DetailView(tabs.TabView):
83
 
    tab_group_class = SnapshotDetailTabs
 
85
    tab_group_class = vol_snsh_tabs.SnapshotDetailTabs
84
86
    template_name = 'project/images_and_snapshots/snapshots/detail.html'