Commit 6af23811 authored by Gabriel Detraz's avatar Gabriel Detraz

Supprime l'embryon de système de management des bornes (buggué)

parent 79f1290d
......@@ -5,16 +5,3 @@ from django import forms
from django.forms import widgets
from django.utils.translation import ugettext_lazy as _
class Wifi_Action(forms.Form):
actions_possibles = forms.ChoiceField(label=_(u'Actions possible sur les bornes '), required=False)
class Wifi_Info(forms.Form):
vlan_select = forms.CharField(label=_(u'Vlan séléctionné'), max_length=40, required=False)
ssid_name = forms.CharField(label=_(u'Nom du ssid'), max_length=40, required=False)
encryption_mode = forms.CharField(label=_(u'Protocole de sécurité (choisir wpa2, psk ou open)'), max_length=40, required=False)
encryption_server = forms.CharField(label=_(u'Serveur Radius (ipv6)'), max_length=60, required=False)
encryption_key = forms.CharField(label=_(u'Clef de Sécurité Radius'), max_length=40, required=False)
class Bornes_Cibles(forms.Form):
batiment = forms.MultipleChoiceField(label=_(u'Action à effectuer sur les batiments '), required=False)
borne = forms.CharField(label=_(u'Action sur une borne en particulier '), max_length=40, required=False)
{% extends "template.html" %}
{% block title %} Mise à jour de la configuration {% endblock %}
{% block h1 %} Mise à jour de la configuration du parc {% endblock %}
{% block content %}
<form class="form-full-width" method="post"> {% csrf_token %}
{% if not option %}
{{ wifi_action.actions_possibles.label_tag }}
{{ wifi_action.actions_possibles }}
{{ wifi_action.actions_possibles.errors }}
{% else %}
<div class="row">
<div class="six columns">
{% if option == "vlan" %}
{{ wifi_info.vlan_select.label_tag }}
{{ wifi_info.vlan_select }}
{{ wifi_info.vlan_select.errors }}
{% elif option == "ssid_enable" or option = "ssid_disable" %}
{{ wifi_info.ssid_name.label_tag }}
{{ wifi_info.ssid_name }}
{{ wifi_info.ssid_name.errors }}
{% elif option == "ssid" %}
{{ wifi_info }}
{% endif %}
</div>
</div>
<div class="row">
<div class="six columns">
{{ bornes_cibles.batiment.label_tag }}
{{ bornes_cibles.batiment }}
{{ bornes_cibles.batiment.errors }}
</div>
<div class="six columns">
{{ bornes_cibles.borne.label_tag }}
{{ bornes_cibles.borne }}
{{ bornes_cibles.borne.errors }}
</div>
</div>
<input type="hidden" value={{ option }} name="option" />
{% endif %}
<footer>
<input type="submit" value="Valider les changements"></td></tr>
</footer>
</form>
{% endblock %}
......@@ -14,11 +14,6 @@
{% endblock %}
{% block content %}
{% if not public %}
<form action="/wifimap/change_conf">
{% csrf_token %}
<input type="submit" value="{% trans "Changer la configuration déployée" %}"></td></tr>
{% endif %}
{% trans "Dernière mise à jour il y a" %}<span id="last_update"></span>
<div class="row">
<div class="four columns" id="toolbar">
......
......@@ -24,7 +24,6 @@ urlpatterns = [
url('^$', views.index),
url('^get_xml$', views.get_xml),
url('^update\((\w+),(\d+\.?\d+),(\d+\.?\d+)\)$', views.update),
url('^change_conf$', views.change_conf),
]
......@@ -27,15 +27,10 @@ from django.views.decorators.csrf import csrf_exempt
from django.contrib import messages
from models import VirtAP
from forms import Wifi_Action
from forms import Bornes_Cibles
from forms import Wifi_Info
from intranet import conn_pool, settings
from lc_ldap.crans_utils import escape as ldap_escape
from gestion.config.config import liste_bats
from wifi_new.manage_borne_conf import exec_conn
from wifi_new import template
from django.utils.translation import ugettext_lazy as _
......@@ -89,70 +84,3 @@ def update(request,hostname, lon, lat):
ap.save()
return HttpResponse(doc.toxml('utf-8'),content_type='text/xml; coding=utf-8')
@permission_required('wifimap.change_virtAP')
def change_conf(request):
wifi_action = Wifi_Action()
bornes_cibles = Bornes_Cibles()
wifi_info = Wifi_Info()
BATS = [(bat,bat) for bat in liste_bats]
BATS.extend((('ens','ENS'),('all','Tous')))
OPTIONS = [('ssid',_(u'Ajouter un SSID')), ('vlan',_(u'Ajouter une interface réseau')), ('ssid_enable',_(u'Activer un SSID (Deja présent !)')), ('ssid_disable',_(u'Désactiver un SSID')), ('hostapd',_(u'Redémarer Hostapd')), ('network',_(u'Redémarer network interfaces'))]
wifi_action.fields['actions_possibles'].choices = tuple(OPTIONS)
bornes_cibles.fields['batiment'].choices = tuple(BATS)
option=False
if request.method == "POST":
# On instancie
wifi_action = Wifi_Action(request.POST)
bornes_cibles = Bornes_Cibles(request.POST)
wifi_info = Wifi_Info(request.POST)
#On formatte
bornes_cibles.fields['batiment'].choices = tuple(BATS)
wifi_action.fields['actions_possibles'].choices = tuple(OPTIONS)
# Etape 1 : selection de l'action
if wifi_action.is_valid() and wifi_action.cleaned_data['actions_possibles']:
#print wifi_action.cleaned_data['actions_possibles']
option = str(wifi_action.cleaned_data['actions_possibles'])
# On renvoie tout pour les menus secondaires.
return django.shortcuts.render(request, 'wifimap/change_conf.html', locals())
# Etape 2 : info supplémentaires et zone cible
if bornes_cibles.is_valid() and 'option' in request.POST.keys():
option = str(request.POST['option'])
#print option
# On récupère la cmd et on formatte
cmd = getattr(template,option)
#print bornes_cibles.cleaned_data['batiment']
#print bornes_cibles.cleaned_data['borne']
# Si c'est pas valide, excepté les cas triviaux, on envoie bouler pour eviter une commande foireuse sur les bornes
if option!="hostapd" or option!="network":
if not wifi_info.is_valid():
return django.shortcuts.render(request, 'wifimap/change_conf.html', locals())
# On format pour les commandes complexes (vlan, add ssid)
if option=="vlan":
cmd = cmd.format(wifi_info.cleaned_data['vlan_select'])
if option=="ssid_enable" or option == "ssid_disable":
cmd = cmd.format(wifi_info.cleaned_data['ssid_name'])
if option=="ssid":
cmd = cmd.format(wifi_info.cleaned_data['vlan_select'],wifi_info.cleaned_data['encryption_mode'], wifi_info.cleaned_data['encryption_server'], wifi_info.cleaned_data['ssid_name'], wifi_info.cleaned_data['encryption_key'])
#print cmd
# On choisi la zone cible et on envoie la commande
if "borne" in bornes_cibles.changed_data:
exec_conn(bats=all, ens=False, cmd="pwd", borne=bornes_cibles.cleaned_data['borne']+".wifi.crans.org")
if "batiment" in bornes_cibles.changed_data:
if bornes_cibles.cleaned_data['batiment'] == u"ens":
exec_conn(bats=all, ens=True, cmd="pwd", borne=False)
else:
exec_conn(bats=bornes_cibles.cleaned_data['batiment'], ens=False, cmd="pwd", borne=False)
# On retourne à l'user
messages.success(request, _(u"""La configuration a été prise en compte"""))
return django.shortcuts.redirect("/wifimap/")
return django.shortcuts.render(request, 'wifimap/change_conf.html', locals())
return django.shortcuts.render(request, 'wifimap/change_conf.html', locals())
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