Commit c85119c5 authored by Daniel STAN's avatar Daniel STAN

[voip] mode test et generalisation confirm

parent 8b7b0cd5
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.contrib import messages
import settings
class asterisk_reload_conf_debug:
@classmethod
def reload_config(self, fname):
pass
import sys
sys.path.append('/usr/scripts/sip/')
try:
import asterisk_reload_conf
except ImportError:
if not settings.DEBUG:
raise
asterisk_reload_conf = asterisk_reload_conf_debug
from django.db import models
from django.contrib.auth.models import User
import hashlib
import os
import asterisk_reload_conf
from django.utils.importlib import import_module
conn_pool = import_module('conn_pool', 'intranet')
# Description de la configuration générée pour asterisk
asterisk_conf = {
'modules':{
......@@ -37,8 +49,6 @@ asterisk_conf = {
'conf_path':'/usr/scripts/var/sip/'
}
class Profile(models.Model):
""" Profil d'utilisateur Voip """
......@@ -99,10 +109,11 @@ class Profile(models.Model):
conf=""
for profile in Profile.objects.order_by('user__username').all():
conf+=gen_conf_module(profile).encode('utf-8') + '\n'
file=open(path + '.new','w')
file.write(conf)
file.close()
os.rename(path + '.new', path)
tmppath = path + '.new'
if not settings.DEBUG:
with open(tmppath,'w') as fout:
fout.write(conf)
os.rename(tmppath, path)
for module in asterisk_conf['modules'].keys():
if modules[module]:
writeconf(
......@@ -138,7 +149,9 @@ class Profile(models.Model):
aid = conn_pool.LDAP_USERS[new_user.username]['aid'][0].value
sip_ext = '1%04d' % int(str(aid)[:4])
except KeyError:
raise Exception("Not allowed") # FIXME
if not settings.DEBUG:
raise Exception("Not allowed") # FIXME ?
sip_ext = '9%04d' % int(str(new_user.pk)[:4])
self.num = sip_ext
def set_password(self, new_pass):
......
......@@ -7,6 +7,7 @@ from django.views.decorators.debug import sensitive_post_parameters
from models import Profile, Call
from forms import ProfileForm
from django.core.urlresolvers import reverse
from django.views.generic.edit import DeleteView
from django.shortcuts import get_object_or_404
......@@ -46,7 +47,11 @@ def delete(request):
if request.method == 'POST':
obj.delete()
return django.shortcuts.redirect('apps.accueil.views.view')
return django.shortcuts.render(request, "voip/delete.html")
return django.shortcuts.render(request, "confirm.html", {
'confirm_title': u'Suppression du compte SIP',
'confirm_message': u'Êtes-vous sûr de vouloir effacer votre compte téléphonique ?',
'confirm_cancel_url': reverse('voip:index'),
})
@login_required
def book(request, download=False):
......
......@@ -58,6 +58,7 @@ ADMINS = (
('Intranet', 'root@crans.org'),
)
MANAGERS = ADMINS
FIXTURE_DIRS=(ROOT_PATH + 'fixtures/',)
......
{% extends "template.html" %}
{% block content %}
<h3>Suppression du compte SIP</h3>
<h3>{{ confirm_title }}</h3>
<p>
Êtes-vous sûr de vouloir effacer votre compte téléphonique ?
<a href="{% url voip:index %}">Retour</a>
{{ confirm_message }}
<a href="{{ confirm_cancel_url }}">Retour</a>
</p>
<form method="post">
{% csrf_token %}
......
{% extends "template.html" %}
{% block content %}
<form method="POST" action="">{% csrf_token %}
<form method="POST" action="" autocomplete="off">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="OK" />
</form>
......
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