Commit efab5d92 by Chif Gergő

request: Add RequestField views

Added views to list, edit, delete RequestField model objects.
parent 294fcb2c
......@@ -24,6 +24,8 @@ from .views import (
TemplateAccessTypeCreate, TemplateAccessTypeDetail,
TemplateRequestView, LeaseRequestView, ResourceRequestView,
LeaseTypeDelete, TemplateAccessTypeDelete, ResizeRequestView,
RequestFieldFormView, RequestFieldListView, RequestFieldDetailView,
RequestFieldDeleteView,
)
urlpatterns = [
......@@ -35,6 +37,13 @@ urlpatterns = [
url(r'^type/list/$', RequestTypeList.as_view(),
name="request.views.type-list"),
url(r'fields/add/$', RequestFieldFormView.as_view(), name='field_add'),
url(r'fields/$', RequestFieldListView.as_view(), name='fields_list'),
url(r'fields/field/(?P<pk>[0-9]+)/$', RequestFieldDetailView.as_view(),
name='fields_detail'),
url(r'^delete/(?P<pk>\d+)/$', RequestFieldDeleteView.as_view(),
name='field_delete'),
# request types
url(r'^type/lease/create/$', LeaseTypeCreate.as_view(),
name="request.views.lease-type-create"),
......
......@@ -18,6 +18,7 @@ from __future__ import unicode_literals, absolute_import
from django.views.generic import (
UpdateView, TemplateView, DetailView, CreateView, FormView, DeleteView,
ListView
)
from django.contrib import messages
from django.contrib.messages.views import SuccessMessageMixin
......@@ -32,7 +33,7 @@ from django_tables2 import SingleTableView
from request.models import (
Request, TemplateAccessType, LeaseType, TemplateAccessAction,
ExtendLeaseAction, ResourceChangeAction, DiskResizeAction
ExtendLeaseAction, ResourceChangeAction, DiskResizeAction, RequestField
)
from storage.models import Disk
from vm.models import Instance
......@@ -42,7 +43,38 @@ from request.tables import (
from request.forms import (
LeaseTypeForm, TemplateAccessTypeForm, TemplateRequestForm,
LeaseRequestForm, ResourceRequestForm, ResizeRequestForm,
RequestFieldModelForm
)
from django.urls import reverse_lazy
class RequestFieldFormView(LoginRequiredMixin, CreateView):
template_name = 'request/field_form.html'
model = RequestField
form_class = RequestFieldModelForm
success_url = reverse_lazy('fields_list')
class RequestFieldListView(LoginRequiredMixin, ListView):
template_name = 'request/field_list.html'
model = RequestField
def get_context_data(self, *args, **kwargs):
ctx = super(RequestFieldListView, self).get_context_data(*args,
**kwargs)
ctx['add_form'] = RequestFieldModelForm()
ctx['requests'] = Request.objects.all()
return ctx
class RequestFieldDetailView(LoginRequiredMixin, DetailView):
model = RequestField
class RequestFieldDeleteView(LoginRequiredMixin, DeleteView):
model = RequestField
success_url = reverse_lazy('fields_list')
class RequestList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment