Commit 484ed29e by Szabolcs Gelencser

Add initial Requests views with permission check

parent 46d06df9
......@@ -315,6 +315,7 @@ TEMPLATES = [{
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.template.context_processors.request',
'django.contrib.messages.context_processors.messages',
'dashboard.context_processors.notifications',
'dashboard.context_processors.extract_settings',
......
......@@ -89,7 +89,7 @@
</div>
<div class="panel-body" id="vm-graph-view" style="display: none">
<p class="pull-right">
<input class="knob" data-fgColor="chartreuse" data-thickness=".4" data-max="{{ request.user.profile.instance_limit }}" data-width="100" data-height="100" data-readOnly="true" value="{{ instances|length|add:more_instances }}">
<input class="knob" data-fgColor="chartreuse" data-thickness=".4" data-max="#TODO" data-width="100" data-height="100" data-readOnly="true" value="{{ instances|length|add:more_instances }}">
</p>
<span class="bigbig">{% blocktrans with count=running_vm_num %}<span class="big-tag">{{ count }}</span> running{% endblocktrans %}</span>
<ul class="list-inline" style="max-height: 95px; overflow: hidden;">
......
......@@ -16,6 +16,7 @@
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals, absolute_import
from braces.views._access import AccessMixin
from django.views.generic import (
UpdateView, TemplateView, DetailView, CreateView, FormView, DeleteView,
)
......@@ -45,7 +46,18 @@ from request.forms import (
)
class RequestList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
class RequestDecideRequiredMixin(AccessMixin):
"""
Mixin allows you to require a user with `is_superuser` set to True.
"""
def dispatch(self, request, *args, **kwargs):
if not self.request.user.permissions["request_decide"]:
return self.handle_no_permission(request)
return super(RequestDecideRequiredMixin, self).dispatch(
request, *args, **kwargs)
class RequestList(LoginRequiredMixin, RequestDecideRequiredMixin, SingleTableView):
model = Request
table_class = RequestTable
template_name = "request/list.html"
......@@ -102,7 +114,7 @@ class RequestDetail(LoginRequiredMixin, DetailView):
return context
class TemplateAccessTypeDetail(LoginRequiredMixin, SuperuserRequiredMixin,
class TemplateAccessTypeDetail(LoginRequiredMixin, RequestDecideRequiredMixin,
SuccessMessageMixin, UpdateView):
model = TemplateAccessType
template_name = "request/template-type-form.html"
......@@ -110,7 +122,7 @@ class TemplateAccessTypeDetail(LoginRequiredMixin, SuperuserRequiredMixin,
success_message = _("Template access type successfully updated.")
class TemplateAccessTypeCreate(LoginRequiredMixin, SuperuserRequiredMixin,
class TemplateAccessTypeCreate(LoginRequiredMixin, RequestDecideRequiredMixin,
SuccessMessageMixin, CreateView):
model = TemplateAccessType
template_name = "request/template-type-form.html"
......@@ -118,7 +130,7 @@ class TemplateAccessTypeCreate(LoginRequiredMixin, SuperuserRequiredMixin,
success_message = _("New template access type successfully created.")
class TemplateAccessTypeDelete(LoginRequiredMixin, SuperuserRequiredMixin,
class TemplateAccessTypeDelete(LoginRequiredMixin, RequestDecideRequiredMixin,
DeleteView):
model = TemplateAccessType
template_name = "dashboard/confirm/base-delete.html"
......@@ -127,7 +139,7 @@ class TemplateAccessTypeDelete(LoginRequiredMixin, SuperuserRequiredMixin,
return reverse("request.views.type-list")
class LeaseTypeDetail(LoginRequiredMixin, SuperuserRequiredMixin,
class LeaseTypeDetail(LoginRequiredMixin, RequestDecideRequiredMixin,
SuccessMessageMixin, UpdateView):
model = LeaseType
template_name = "request/lease-type-form.html"
......@@ -135,7 +147,7 @@ class LeaseTypeDetail(LoginRequiredMixin, SuperuserRequiredMixin,
success_message = _("Lease type successfully updated.")
class LeaseTypeCreate(LoginRequiredMixin, SuperuserRequiredMixin,
class LeaseTypeCreate(LoginRequiredMixin, RequestDecideRequiredMixin,
SuccessMessageMixin, CreateView):
model = LeaseType
template_name = "request/lease-type-form.html"
......@@ -143,7 +155,7 @@ class LeaseTypeCreate(LoginRequiredMixin, SuperuserRequiredMixin,
success_message = _("New lease type successfully created.")
class LeaseTypeDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
class LeaseTypeDelete(LoginRequiredMixin, RequestDecideRequiredMixin, DeleteView):
model = LeaseType
template_name = "dashboard/confirm/base-delete.html"
......@@ -151,7 +163,7 @@ class LeaseTypeDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
return reverse("request.views.type-list")
class RequestTypeList(LoginRequiredMixin, SuperuserRequiredMixin,
class RequestTypeList(LoginRequiredMixin, RequestDecideRequiredMixin,
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