Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
# vim: tabstop=4 shiftwidth=4 softtabstop=4

# Copyright (c) 2013 TrilioData, Inc.


import logging

try:
    from django.core.urlresolvers import reverse
except ImportError:
    from django.urls import reverse
try:
    from django.core.urlresolvers import reverse_lazy
except ImportError:
    from django.urls import reverse_lazy

from django.utils.translation import ugettext_lazy as _

from horizon import exceptions
from horizon import messages
from horizon import tables

from dashboards import workloadmgr
from openstack_dashboard import api

LOG = logging.getLogger(__name__)


class Delete(tables.DeleteAction):
    data_type_singular = _("Testbubble")
    data_type_plural = _("Testbubbles")

    @staticmethod
    def action_present(count):
        return _("Delete Testbubbles")

    @staticmethod
    def action_past(count):
        return _("Deleted")

    def delete(self, request, obj_id):
        try:
            workloadmgr.testbubble_delete(request, obj_id)
        except Exception as ex:
            messages.error(request, str(ex))


class UpdateRow(tables.Row):
    ajax = True

    def get_data(self, request, testbubble_id):
        testbubble = workloadmgr.testbubble_get(request, testbubble_id)
        return testbubble


class TestbubblesTable(tables.DataTable):
    STATUS_CHOICES = (
        ("available", True),
        ("error", True)
    )

    time_stamp = tables.Column("created_at", verbose_name=_("Time Stamp"))
    id = tables.Column("id", verbose_name=_("ID"))
    status = tables.Column("status",
                           verbose_name=_("Status"),
                           status=True,
                           status_choices=STATUS_CHOICES)
    failure_url = reverse_lazy('horizon:project:workloads:snapshots:detail')

    class Meta:
        name = "testbubbles"
        verbose_name = _("Testbubbles")
        status_columns = ["status", "status"]
        row_class = UpdateRow
        table_actions = (Delete,)
        row_actions = (Delete,)