Commit d09f8aef by Kálmán Viktor

request: delete view for request types

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