mistral-dashboard/mistraldashboard/cron_triggers/views.py
Akihiro Motoki 3ae1e8aae3 Django 2.0 support
Replace django.core.urlresolves with django.urls

(In Django 2.0) The django.core.urlresolvers module is removed
in favor of its new location, django.urls.
It was deprecated in Django 1.10:
https://docs.djangoproject.com/en/2.0/releases/1.10/#id3

Add py35dj20 job to test Django 2.0 integration.

Change-Id: I6d2e38201387012ba9a02c4b0bd8377895a5919a
2018-05-15 06:14:48 +09:00

80 lines
2.6 KiB
Python

# Copyright 2016 - Nokia.
#
# 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.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.views import generic
from horizon import forms
from horizon import tables
from mistraldashboard import api
from mistraldashboard.cron_triggers import forms as mistral_forms
from mistraldashboard.cron_triggers import tables as mistral_tables
class OverviewView(generic.TemplateView):
template_name = 'mistral/cron_triggers/detail.html'
page_title = _("Cron Trigger Details")
workflow_url = 'horizon:mistral:workflows:detail'
list_url = 'horizon:mistral:cron_triggers:index'
def get_context_data(self, **kwargs):
context = super(OverviewView, self).get_context_data(**kwargs)
cron_trigger = {}
cron_trigger = api.cron_trigger_get(
self.request,
kwargs['cron_trigger_name']
)
cron_trigger.workflow_url = reverse(
self.workflow_url,
args=[cron_trigger.workflow_name]
)
cron_trigger.list_url = reverse_lazy(self.list_url)
breadcrumb = [(cron_trigger.name, reverse(
'horizon:mistral:cron_triggers:detail',
args=[cron_trigger.name]
))]
context["custom_breadcrumb"] = breadcrumb
context['cron_trigger'] = cron_trigger
return context
class CreateView(forms.ModalFormView):
template_name = 'mistral/cron_triggers/create.html'
modal_header = _("Create Cron Trigger")
form_id = "create_cron_trigger"
form_class = mistral_forms.CreateForm
submit_label = _("Create Cron Trigger")
submit_url = reverse_lazy("horizon:mistral:cron_triggers:create")
success_url = reverse_lazy('horizon:mistral:cron_triggers:index')
page_title = _("Create Cron Trigger")
def get_form_kwargs(self):
kwargs = super(CreateView, self).get_form_kwargs()
return kwargs
class IndexView(tables.DataTableView):
table_class = mistral_tables.CronTriggersTable
template_name = 'mistral/cron_triggers/index.html'
def get_data(self):
return api.cron_trigger_list(self.request)