
django.utils.translation.ugettext(), ugettext_lazy(), ugettext_noop(), ungettext(), and ungettext_lazy() are deprecated in favor of the functions that they’re aliases for: django.utils.translation.gettext(), gettext_lazy(), gettext_noop(), ngettext(), and ngettext_lazy(). On top of that django.conf.urls.url() is deprecated in favor of django.urls.re_path() Since Horizon is using Django>4.0, it's highly important to cover these issues for upcoming release. https: //docs.djangoproject.com/en/4.0/releases/3.0/#id3 Change-Id: Ibefe848cf73a31608ce5e71f4847b741ec16f8ad
67 lines
2.5 KiB
Python
67 lines
2.5 KiB
Python
# Copyright (c) 2016 Catalyst IT Ltd.
|
|
#
|
|
# 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.urls import reverse
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
from horizon import exceptions
|
|
from horizon import tabs
|
|
from horizon import views
|
|
|
|
from horizon.utils import memoized
|
|
|
|
from adjutant_ui.api import adjutant
|
|
from adjutant_ui.content.notifications import tables as notification_tables
|
|
from adjutant_ui.content.notifications import tabs as notification_tab
|
|
|
|
|
|
class IndexView(tabs.TabbedTableView):
|
|
tab_group_class = notification_tab.NotificationTabGroup
|
|
template_name = 'notifications/index.html'
|
|
redirect_url = 'horizon:management:notifications:index'
|
|
page_title = _("Admin Notifications")
|
|
|
|
|
|
class NotificationDetailView(views.HorizonTemplateView):
|
|
redirect_url = "horizon:management:notifications:index"
|
|
template_name = 'notifications/detail.html'
|
|
page_title = "Notification: {{ notification.uuid }}"
|
|
|
|
def get_context_data(self, **kwargs):
|
|
context = super(NotificationDetailView, self).get_context_data(
|
|
**kwargs)
|
|
notification, task = self.get_data()
|
|
context["notification"] = notification
|
|
context['task'] = task
|
|
context["url"] = reverse(self.redirect_url)
|
|
context["actions"] = self._get_actions(notification=notification)
|
|
return context
|
|
|
|
def _get_actions(self, notification):
|
|
table = notification_tables.NotificationTable(self.request)
|
|
return table.render_row_actions(notification)
|
|
|
|
@memoized.memoized_method
|
|
def get_data(self):
|
|
try:
|
|
notification = adjutant.notification_obj_get(
|
|
self.request, self.kwargs['notif_id'])
|
|
task = adjutant.task_obj_get(self.request,
|
|
task_id=notification.task)
|
|
return notification, task
|
|
except Exception:
|
|
msg = _('Unable to retrieve notification.')
|
|
url = reverse('horizon:management:notifications:index')
|
|
exceptions.handle(self.request, msg, redirect=url)
|