castellan_ui.content.opaque_data.tables

Source code for castellan_ui.content.opaque_data.tables

#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.


from castellan_ui.content import filters
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy

from castellan_ui.api import client
from horizon import tables


[docs]class ImportOpaqueData(tables.LinkAction): name = "import_opaque_data" verbose_name = _("Import Opaque Data") url = "horizon:project:opaque_data:import" classes = ("ajax-modal",) icon = "upload" policy_rules = ()
[docs]class DownloadOpaqueData(tables.LinkAction): name = "download" verbose_name = _("Download Opaque Data") url = "horizon:project:opaque_data:download" classes = ("btn-download",) policy_rules = ()
[docs]class DeleteOpaqueData(tables.DeleteAction): policy_rules = () help_text = _("You should not delete an object unless you are " "certain it is not being used anywhere.")
[docs] @staticmethod def action_present(count): return ungettext_lazy( u"Delete Opaque Data", u"Delete Opaque Data", count )
[docs] @staticmethod def action_past(count): return ungettext_lazy( u"Deleted Opaque Data", u"Deleted Opaque Data", count )
[docs] def delete(self, request, obj_id): client.delete(request, obj_id)
[docs]class OpaqueDataTable(tables.DataTable): detail_link = "horizon:project:opaque_data:detail" uuid = tables.Column("id", verbose_name=_("Object ID"), link=detail_link) name = tables.Column("name", verbose_name=_("Name")) created_date = tables.Column("created", verbose_name=_("Created Date"), filters=(filters.timestamp_to_iso,))
[docs] def get_object_display(self, datum): return datum.name if datum.name else datum.id
[docs] class Meta(object): name = "opaque_data" table_actions = (ImportOpaqueData, DeleteOpaqueData,) row_actions = (DownloadOpaqueData, DeleteOpaqueData)
Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.