Commit d09f8aef by Kálmán Viktor

request: delete view for request types

parent f08a4701
...@@ -1311,3 +1311,7 @@ textarea[name="new_members"] { ...@@ -1311,3 +1311,7 @@ textarea[name="new_members"] {
.nowrap { .nowrap {
white-space: nowrap; white-space: nowrap;
} }
.little-margin-bottom {
margin-bottom: 5px;
}
...@@ -47,7 +47,7 @@ class RequestAction(Model): ...@@ -47,7 +47,7 @@ class RequestAction(Model):
class RequestType(Model): class RequestType(Model):
name = CharField(max_length=25) name = CharField(max_length=25, verbose_name=_("Name"))
def __unicode__(self): def __unicode__(self):
return self.name return self.name
...@@ -128,7 +128,7 @@ class Request(TimeStampedModel): ...@@ -128,7 +128,7 @@ class Request(TimeStampedModel):
class LeaseType(RequestType): class LeaseType(RequestType):
lease = ForeignKey(Lease) lease = ForeignKey(Lease, verbose_name=_("Lease"))
def __unicode__(self): def __unicode__(self):
return _("%(name)s (suspend: %(s)s, remove: %(r)s)") % { return _("%(name)s (suspend: %(s)s, remove: %(r)s)") % {
...@@ -142,7 +142,7 @@ class LeaseType(RequestType): ...@@ -142,7 +142,7 @@ class LeaseType(RequestType):
class TemplateAccessType(RequestType): class TemplateAccessType(RequestType):
templates = ManyToManyField(InstanceTemplate) templates = ManyToManyField(InstanceTemplate, verbose_name=_("Templates"))
def get_absolute_url(self): def get_absolute_url(self):
return reverse("request.views.template-type-detail", return reverse("request.views.template-type-detail",
......
...@@ -14,9 +14,17 @@ ...@@ -14,9 +14,17 @@
<div class="col-md-12"> <div class="col-md-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<a class="btn btn-xs btn-default pull-right" href="{% url "request.views.type-list" %}"> <div class="pull-right">
{% if object.pk %}
<a class="btn btn-xs btn-danger"
href="{% url "request.views.lease-type-delete" pk=object.pk %}">
<i class="fa fa-times"></i> {% trans "Delete" %}
</a>
{% endif %}
<a class="btn btn-xs btn-default" href="{% url "request.views.type-list" %}">
{% trans "Back" %} {% trans "Back" %}
</a> </a>
</div>
<h3 class="no-margin"> <h3 class="no-margin">
<i class="fa fa-clock-o"></i> <i class="fa fa-clock-o"></i>
{% if form.instance.pk %} {% if form.instance.pk %}
......
...@@ -14,9 +14,17 @@ ...@@ -14,9 +14,17 @@
<div class="col-md-12"> <div class="col-md-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<a class="btn btn-xs btn-default pull-right" href="{% url "request.views.type-list" %}"> <div class="pull-right">
{% if object.pk %}
<a class="btn btn-xs btn-danger"
href="{% url "request.views.template-type-delete" pk=object.pk %}">
<i class="fa fa-times"></i> {% trans "Delete" %}
</a>
{% endif %}
<a class="btn btn-xs btn-default" href="{% url "request.views.type-list" %}">
{% trans "Back" %} {% trans "Back" %}
</a> </a>
</div>
<h3 class="no-margin"> <h3 class="no-margin">
<i class="fa fa-puzzle-piece"></i> <i class="fa fa-puzzle-piece"></i>
{% if form.instance.pk %} {% if form.instance.pk %}
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
{% load i18n %} {% load i18n %}
{% load render_table from django_tables2 %} {% load render_table from django_tables2 %}
{% block title-page %}{% trans "Group list" %}{% endblock %} {% block title-page %}{% trans "Request types" %}{% endblock %}
{% block content %} {% block content %}
...@@ -24,13 +24,21 @@ ...@@ -24,13 +24,21 @@
<h3 class="no-margin"><i class="fa fa-phone"></i> {% trans "Request types" %}</h3> <h3 class="no-margin"><i class="fa fa-phone"></i> {% trans "Request types" %}</h3>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<div id="table_container"> <div class="text-muted little-margin-bottom">
<div id="rendered_table" class="panel-body"> {% trans "Lease types are used for sharing leases. User can request longer ones via these." %}
</div>
<div class="table-responsive"> <div class="table-responsive">
{% render_table lease_table %} {% render_table lease_table %}
{% render_table template_table %}
</div> </div>
<div class="text-muted little-margin-bottom">
{% blocktrans %}
Template access types are used for sharing multiple templates with users.
They can request these with user or operator level access on the included templates.
{% endblocktrans %}
</div> </div>
<div class="table-responsive">
{% render_table template_table %}
</div> </div>
</div><!-- .panel-body --> </div><!-- .panel-body -->
</div> </div>
......
...@@ -23,6 +23,7 @@ from .views import ( ...@@ -23,6 +23,7 @@ from .views import (
LeaseTypeCreate, LeaseTypeDetail, LeaseTypeCreate, LeaseTypeDetail,
TemplateAccessTypeCreate, TemplateAccessTypeDetail, TemplateAccessTypeCreate, TemplateAccessTypeDetail,
TemplateRequestView, LeaseRequestView, ResourceRequestView, TemplateRequestView, LeaseRequestView, ResourceRequestView,
LeaseTypeDelete, TemplateAccessTypeDelete,
) )
urlpatterns = patterns( urlpatterns = patterns(
...@@ -35,17 +36,24 @@ urlpatterns = patterns( ...@@ -35,17 +36,24 @@ urlpatterns = patterns(
url(r'^type/list/$', RequestTypeList.as_view(), url(r'^type/list/$', RequestTypeList.as_view(),
name="request.views.type-list"), name="request.views.type-list"),
# request types
url(r'^type/lease/create/$', LeaseTypeCreate.as_view(), url(r'^type/lease/create/$', LeaseTypeCreate.as_view(),
name="request.views.lease-type-create"), name="request.views.lease-type-create"),
url(r'^type/lease/(?P<pk>\d+)/$', LeaseTypeDetail.as_view(), url(r'^type/lease/(?P<pk>\d+)/$', LeaseTypeDetail.as_view(),
name="request.views.lease-type-detail"), name="request.views.lease-type-detail"),
url(r'^type/lease/delete/(?P<pk>\d+)/$', LeaseTypeDelete.as_view(),
name="request.views.lease-type-delete"),
url(r'^type/template/create/$', TemplateAccessTypeCreate.as_view(), url(r'^type/template/create/$', TemplateAccessTypeCreate.as_view(),
name="request.views.template-type-create"), name="request.views.template-type-create"),
url(r'^type/template/(?P<pk>\d+)/$', url(r'^type/template/(?P<pk>\d+)/$',
TemplateAccessTypeDetail.as_view(), TemplateAccessTypeDetail.as_view(),
name="request.views.template-type-detail"), name="request.views.template-type-detail"),
url(r'^type/template/delete/(?P<pk>\d+)/$',
TemplateAccessTypeDelete.as_view(),
name="request.views.template-type-delete"),
# request views (visible for users)
url(r'template/$', TemplateRequestView.as_view(), url(r'template/$', TemplateRequestView.as_view(),
name="request.views.request-template"), name="request.views.request-template"),
url(r'lease/(?P<vm_pk>\d+)/$', LeaseRequestView.as_view(), url(r'lease/(?P<vm_pk>\d+)/$', LeaseRequestView.as_view(),
......
...@@ -17,10 +17,11 @@ ...@@ -17,10 +17,11 @@
from __future__ import unicode_literals, absolute_import from __future__ import unicode_literals, absolute_import
from django.views.generic import ( from django.views.generic import (
UpdateView, TemplateView, DetailView, CreateView, FormView, UpdateView, TemplateView, DetailView, CreateView, FormView, DeleteView,
) )
from django.shortcuts import redirect, get_object_or_404 from django.shortcuts import redirect, get_object_or_404
from django.core.exceptions import PermissionDenied, SuspiciousOperation from django.core.exceptions import PermissionDenied, SuspiciousOperation
from django.core.urlresolvers import reverse
from braces.views import SuperuserRequiredMixin, LoginRequiredMixin from braces.views import SuperuserRequiredMixin, LoginRequiredMixin
from django_tables2 import SingleTableView from django_tables2 import SingleTableView
...@@ -109,6 +110,15 @@ class TemplateAccessTypeCreate(LoginRequiredMixin, SuperuserRequiredMixin, ...@@ -109,6 +110,15 @@ class TemplateAccessTypeCreate(LoginRequiredMixin, SuperuserRequiredMixin,
form_class = TemplateAccessTypeForm form_class = TemplateAccessTypeForm
class TemplateAccessTypeDelete(LoginRequiredMixin, SuperuserRequiredMixin,
DeleteView):
model = TemplateAccessType
template_name = "dashboard/confirm/base-delete.html"
def get_success_url(self):
return reverse("request.views.type-list")
class LeaseTypeDetail(LoginRequiredMixin, SuperuserRequiredMixin, UpdateView): class LeaseTypeDetail(LoginRequiredMixin, SuperuserRequiredMixin, UpdateView):
model = LeaseType model = LeaseType
template_name = "request/lease-type-form.html" template_name = "request/lease-type-form.html"
...@@ -121,6 +131,14 @@ class LeaseTypeCreate(LoginRequiredMixin, SuperuserRequiredMixin, CreateView): ...@@ -121,6 +131,14 @@ class LeaseTypeCreate(LoginRequiredMixin, SuperuserRequiredMixin, CreateView):
form_class = LeaseTypeForm form_class = LeaseTypeForm
class LeaseTypeDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
model = LeaseType
template_name = "dashboard/confirm/base-delete.html"
def get_success_url(self):
return reverse("request.views.type-list")
class RequestTypeList(LoginRequiredMixin, SuperuserRequiredMixin, class RequestTypeList(LoginRequiredMixin, SuperuserRequiredMixin,
TemplateView): TemplateView):
template_name = "request/type-list.html" template_name = "request/type-list.html"
......
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