From b455de0de2bafaac6b5d1654be95a9262158422d Mon Sep 17 00:00:00 2001 From: grisel-davy Date: Thu, 9 Aug 2018 11:39:44 +0200 Subject: [PATCH] bouton de regen des services --- machines/templates/machines/aff_service.html | 5 +++-- machines/urls.py | 1 + machines/views.py | 12 +++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/machines/templates/machines/aff_service.html b/machines/templates/machines/aff_service.html index 6ca6278b..8dc2e729 100644 --- a/machines/templates/machines/aff_service.html +++ b/machines/templates/machines/aff_service.html @@ -32,7 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc., Temps minimum avant nouvelle régénération Temps avant nouvelle génération obligatoire (max) Serveurs inclus - + Demander la regeneration @@ -41,7 +41,8 @@ with this program; if not, write to the Free Software Foundation, Inc., {{ service.service_type }} {{ service.min_time_regen }} {{ service.regular_time_regen }} - {% for serv in service.servers.all %}{{ serv }}, {% endfor %} + {% for serv in service.servers.all %}{{ serv }}, {% endfor %} + {% can_edit service %} {% include 'buttons/edit.html' with href='machines:edit-service' id=service.id %} diff --git a/machines/urls.py b/machines/urls.py index 8c670308..d6f3a541 100644 --- a/machines/urls.py +++ b/machines/urls.py @@ -124,6 +124,7 @@ urlpatterns = [ views.edit_service, name='edit-service'), url(r'^del_service/$', views.del_service, name='del-service'), + url(r'^regen_service/(?P[0-9]+)$', views.regen_service, name='regen-service'), url(r'^index_service/$', views.index_service, name='index-service'), url(r'^add_role/$', views.add_role, name='add-role'), url(r'^edit_role/(?P[0-9]+)$', diff --git a/machines/views.py b/machines/views.py index 3509be43..f7d138be 100644 --- a/machines/views.py +++ b/machines/views.py @@ -33,7 +33,7 @@ The views for the Machines app from __future__ import unicode_literals from django.urls import reverse -from django.http import HttpResponse +from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import render, redirect from django.contrib import messages from django.contrib.auth.decorators import login_required, permission_required @@ -128,6 +128,7 @@ from .models import ( Role, Service, Service_link, + regen, Vlan, Nas, Txt, @@ -1261,6 +1262,15 @@ def del_service(request, instances): request ) +@login_required +@can_edit(Service) +def regen_service(request,service, **_kwargs): + """Ask for a regen of the service""" + + regen(service) + return index_service(request) + + @login_required @can_create(Vlan)