Files
freezer-web-ui/freezer_ui/actions/tables.py
Ivan Anfimov b2658648e5 Fix for various mistakes with spaces and remove * at the fields since such is not used anywhere in Horizon
Change-Id: Ic1606782ff0bfca2a201be012891f00a61ebbb70
Signed-off-by: Ivan Anfimov <lazekteam@gmail.com>
2025-09-05 11:54:34 +00:00

107 lines
3.2 KiB
Python

# 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 django import shortcuts
from django.utils.translation import gettext_lazy as _
from django.utils.translation import ngettext_lazy
from horizon import tables
from django.urls import reverse
import freezer_ui.api.api as freezer_api
class DeleteAction(tables.DeleteAction):
help_text = _("Deleted Actions is not recoverable.")
@staticmethod
def action_present(count):
return ngettext_lazy(
"Delete Action",
"Delete Actions",
count
)
@staticmethod
def action_past(count):
return ngettext_lazy(
"Deleted Action",
"Deleted Actions",
count
)
def delete(self, request, action_id):
freezer_api.Action(request).delete(action_id)
# TODO(m3m0): this shouldnt redirect here when an action is deleted
# from jobs views
return shortcuts.redirect('horizon:disaster_recovery:actions:index')
class DeleteMultipleActions(DeleteAction):
name = "delete_multiple_actions"
class Filter(tables.FilterAction):
filter_type = "server"
filter_choices = (("exact", "Exact text", True),)
class CreateAction(tables.LinkAction):
name = "create_action"
verbose_name = _("Create Action")
url = "horizon:disaster_recovery:actions:create"
classes = ("ajax-modal",)
icon = "plus"
class EditAction(tables.LinkAction):
name = "edit_action"
verbose_name = _("Edit")
classes = ("ajax-modal",)
icon = "pencil"
def get_link_url(self, datum=None):
return reverse("horizon:disaster_recovery:actions:create",
kwargs={'action_id': datum.action_id})
def get_link(action):
return reverse('horizon:disaster_recovery:actions:action',
kwargs={'action_id': action.id})
class UpdateRow(tables.Row):
ajax = True
class ActionsTable(tables.DataTable):
backup_name = tables.Column('backup_name',
verbose_name=_("Action Name"),
link=get_link)
action = tables.Column('action', verbose_name=_("Action"))
path_to_backup = tables.Column('path_to_backup',
verbose_name=_("Path To Backup or Restore"))
storage = tables.Column('storage', verbose_name=_("Storage"))
mode = tables.Column('mode', verbose_name=_("Mode"))
def get_object_display(self, action):
return action.backup_name
class Meta:
name = "actions_table"
verbose_name = _("Actions")
row_actions = (EditAction, DeleteAction,)
table_actions = (Filter, CreateAction, DeleteMultipleActions)
multi_select = True
row_class = UpdateRow