Commit 1e7c95cc authored by Charlie Jacomme's avatar Charlie Jacomme

[machines] Impression de ticket

parent 01dda584
......@@ -75,7 +75,11 @@
<div class="row">
<a href="{% url 'machines:edit' machine.mid %}"><button>Modifier les informations</button></a>
{% if 'auth.crans_cableur' in perms %}
<a href="{% url 'machines:print_ticket' machine.mid %}"><button>Imprimer un ticket</button></a>
{% endif %}
<a href="{% url 'machines:delete' machine.mid %}"><button class="button-del">Supprimer ma machine</button></a>
</div>
{% if machine.ipsec %}
<h2>Identifiants WiFi</h2>
......
......@@ -12,6 +12,7 @@ urlpatterns = [
url('^(?P<mid>[0-9]+)/advanced/ssh_keys/$', views.ssh_keys, name='ssh_keys'),
url('^(?P<mid>[0-9]+)/advanced/ssh_keys/delete/(?P<delete>[0-9]+)$', views.ssh_keys, name='ssh_keys_delete'),
url('^(?P<mid>[0-9]+)/delete/$', views.delete, name='delete'),
url('^(?P<mid>[0-9]+)/printticket/$', views.print_ticket, name='print_ticket'),
url('^add/(?P<mtype>fil|wifi)/$', views.add, name='add'),
url('^add/(?P<mtype>fil|wifi)/(?P<mac>([0-9a-f]{2}:){5}[0-9a-f]{2})/$', views.add, name='add'),
url('^add/(?P<mtype>fil|wifi)/(?P<ptype>club)/(?P<cid>[0-9]+)/$', views.add, name='add'),
......
......@@ -11,13 +11,13 @@ from django.contrib import messages
from lc_ldap.ldap_locks import LockError
from django.contrib import messages
from intranet import conn_pool, settings
from intranet.mixins import CableurMixin
from lc_ldap import attributs
from django.views.generic import View
import models
import hashlib
import time
import subprocess
from forms import MachineForm
def unicode_of_Error(x):
......@@ -180,6 +180,17 @@ def add(request, mtype=None, cid=None, mac=None, aid=None, ptype=None):
form = MachineForm(initial=initial)
return render(request, 'machines/add_edit.html', {'form' : form})
class PrintTicket(CableurMixin, View):
"""
Classe pour la réinitialisation du mot de passe et l'impression d'un ticket
"""
def get(self, request, mid, *args, **kwargs):
subprocess.call(['/usr/scripts/cransticket/dump_creds.py', '--forced', 'mid=%s' % mid])
messages.success(request, u"""Ticket en cours d'impression.""")
return redirect('machines:detail', mid=mid)
print_ticket = PrintTicket.as_view()
@login_required
def edit(request, mid=None):
# TODO factoriser !
......
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 to comment