mirror of https://github.com/jumpserver/jumpserver
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.0 KiB
73 lines
2.0 KiB
# -*- coding: utf-8 -*-
|
|
#
|
|
|
|
from django.views.generic import TemplateView, CreateView, \
|
|
UpdateView, DeleteView, DetailView
|
|
from django.utils.translation import ugettext_lazy as _
|
|
from django.urls import reverse_lazy
|
|
|
|
from common.permissions import AdminUserRequiredMixin
|
|
from common.const import create_success_msg, update_success_msg
|
|
from ..models import Label
|
|
from ..forms import LabelForm
|
|
|
|
|
|
__all__ = (
|
|
"LabelListView", "LabelCreateView", "LabelUpdateView",
|
|
"LabelDetailView", "LabelDeleteView",
|
|
)
|
|
|
|
|
|
class LabelListView(AdminUserRequiredMixin, TemplateView):
|
|
template_name = 'assets/label_list.html'
|
|
|
|
def get_context_data(self, **kwargs):
|
|
context = {
|
|
'app': _('Assets'),
|
|
'action': _('Label list'),
|
|
}
|
|
kwargs.update(context)
|
|
return super().get_context_data(**kwargs)
|
|
|
|
|
|
class LabelCreateView(AdminUserRequiredMixin, CreateView):
|
|
model = Label
|
|
template_name = 'assets/label_create_update.html'
|
|
form_class = LabelForm
|
|
success_url = reverse_lazy('assets:label-list')
|
|
success_message = create_success_msg
|
|
|
|
def get_context_data(self, **kwargs):
|
|
context = {
|
|
'app': _('Assets'),
|
|
'action': _('Create label'),
|
|
}
|
|
kwargs.update(context)
|
|
return super().get_context_data(**kwargs)
|
|
|
|
|
|
class LabelUpdateView(AdminUserRequiredMixin, UpdateView):
|
|
model = Label
|
|
template_name = 'assets/label_create_update.html'
|
|
form_class = LabelForm
|
|
success_url = reverse_lazy('assets:label-list')
|
|
success_message = update_success_msg
|
|
|
|
def get_context_data(self, **kwargs):
|
|
context = {
|
|
'app': _('Assets'),
|
|
'action': _('Update label'),
|
|
}
|
|
kwargs.update(context)
|
|
return super().get_context_data(**kwargs)
|
|
|
|
|
|
class LabelDetailView(AdminUserRequiredMixin, DetailView):
|
|
pass
|
|
|
|
|
|
class LabelDeleteView(AdminUserRequiredMixin, DeleteView):
|
|
model = Label
|
|
template_name = 'delete_confirm.html'
|
|
success_url = reverse_lazy('assets:label-list')
|