[registration] ajour de plusieurs adresses mac + saisie simplifiée des

adresses mac adaptée pour MacOS avec tous les fichiers cette fois-çi
This commit is contained in:
Romain Beuque 2014-09-20 13:17:58 +02:00
parent 8d4ab84bb3
commit 74a4c9a256
6 changed files with 108 additions and 55 deletions

View File

@ -159,7 +159,10 @@ class NewRegistrationController(AuthenticatedRestController):
@expose() @expose()
def post(self, residence, sn, givenName, mail, phone, def post(self, residence, sn, givenName, mail, phone,
room_uid, first_machine_name, first_machine_mac, room_uid, first_machine_name, first_machine_mac,
next_end, extra_name, group_cn next_end, extra_name, group_cn,
second_machine_name = "", second_machine_mac = "",
third_machine_name = "", third_machine_mac = "",
fourth_machine_name = "", fourth_machine_mac = "",
): ):
# Initialisation des Users des Controllers Existant appellés # Initialisation des Users des Controllers Existant appellés
self.member_edit_controller.add.user = self.user self.member_edit_controller.add.user = self.user
@ -192,25 +195,30 @@ class NewRegistrationController(AuthenticatedRestController):
self.member_edit_controller.room.move.post(residence, member_uid, room_uid, erase = True, go_redirect = False) self.member_edit_controller.room.move.post(residence, member_uid, room_uid, erase = True, go_redirect = False)
#end if #end if
trigerErreur = False
try:
self.member_edit_controller.machine.add.post(residence, member_uid, first_machine_name, first_machine_mac, go_redirect = False)
except:
trigerErreur = True
try:
self.member_edit_controller.cotisation.add.post(residence, member_uid, next_end, extra_name, go_redirect = False)
except:
trigerErreur = True
try: try:
if first_machine_name != "" and first_machine_mac != "":
self.member_edit_controller.machine.add.post(residence, member_uid, first_machine_name, first_machine_mac, go_redirect = False)
#end if
if second_machine_name != "" and second_machine_mac != "":
self.member_edit_controller.machine.add.post(residence, member_uid, second_machine_name, second_machine_mac, go_redirect = False)
#end if
if third_machine_name != "" and third_machine_mac != "":
self.member_edit_controller.machine.add.post(residence, member_uid, third_machine_name, third_machine_mac, go_redirect = False)
#end if
if fourth_machine_name != "" and fourth_machine_mac != "":
self.member_edit_controller.machine.add.post(residence, member_uid, fourth_machine_name, fourth_machine_mac, go_redirect = False)
#end if
if next_end != "" or extra_name != "":
self.member_edit_controller.cotisation.add.post(residence, member_uid, next_end, extra_name, go_redirect = False)
#end if
if group_cn != "": if group_cn != "":
self.administration_controller.groups.add_member.post(group_cn, member.dn, go_redirect = False) self.administration_controller.groups.add_member.post(group_cn, member.dn, go_redirect = False)
#end if #end if
except: except:
trigerErreur = True
if trigerErreur:
redirect("/registration/error/" + member_uid) redirect("/registration/error/" + member_uid)
#end trycatch
redirect("/registration/") redirect("/registration/")
#end def #end def

View File

@ -23,7 +23,7 @@
} }
input[type="text"],input[type="password"] input[type="text"],input[type="password"],input[type=email]
{ {
height: 28px; height: 28px;
} }

View File

@ -1,36 +1,64 @@
function mac_address_correcter(event){ function mac_address_correcter(event){
var valeur = document.getElementById("mac_adress_input").value; if($("#disablevalid:checked").length == 1){ return; }
console.log(document.getElementById("mac_adress_input").value); //si on tape sur backspace ou delete
var regex = /&/g; if(event.keyCode == 8 || event.keyCode == 46) { return; }
valeur = valeur.replace(regex, "1"); var valeur = $(this).val();
var regex = /é/g; var os = $("#osRegister").val();
valeur = valeur.replace(regex, "2"); console.log(valeur);
var regex = /"/g; var regex = Array();
valeur = valeur.replace(regex, "3"); regex['win'] = Array(/&/g, /é/g, /"/g, /'/g, /\(/g, /-/g, /è/g, /_/g, /ç/g, /à/g);
var regex = /'/g; regex['mac'] = Array(/&/g, /é/g, /"/g, /'/g, /\(/g, /§/g, /è/g, /\!/g, /ç/g, /à/g);
valeur = valeur.replace(regex, "4"); valeur = valeur.replace(regex[os][0], "1");
var regex = /\(/g; valeur = valeur.replace(regex[os][1], "2");
valeur = valeur.replace(regex, "5"); valeur = valeur.replace(regex[os][2], "3");
var regex = /-/g; valeur = valeur.replace(regex[os][3], "4");
valeur = valeur.replace(regex, "6"); valeur = valeur.replace(regex[os][4], "5");
var regex = /è/g; valeur = valeur.replace(regex[os][5], "6");
valeur = valeur.replace(regex, "7"); valeur = valeur.replace(regex[os][6], "7");
var regex = /_/g; valeur = valeur.replace(regex[os][7], "8");
valeur = valeur.replace(regex, "8"); valeur = valeur.replace(regex[os][8], "9");
var regex = /ç/g; valeur = valeur.replace(regex[os][9], "0");
valeur = valeur.replace(regex, "9");
var regex = /à/g;
valeur = valeur.replace(regex, "0");
if(valeur.length == 2 || valeur.length == 5 || valeur.length == 8 || valeur.length == 11 || valeur.length == 14){ if(valeur.length == 2 || valeur.length == 5 || valeur.length == 8 || valeur.length == 11 || valeur.length == 14){
valeur = valeur + ":"; valeur = valeur + ":";
document.getElementById("mac_adress_input").value = valeur; $(this).val(valeur);
} }
var regex = /::/g; var regex = /::/g;
valeur = valeur.replace(regex, ":"); valeur = valeur.replace(regex, ":");
if(document.getElementById("mac_adress_input").value != valeur){ if($(this).val() != valeur){
document.getElementById("mac_adress_input").value = valeur; $(this).val(valeur);
} }
var regex = /[^A-Fa-f0-9:]/gi; var regex = /[^A-Fa-f0-9:]/gi;
if(valeur.search(regex) != -1) if(valeur.search(regex) != -1 || valeur.length > 17){
alert("ERREUR"); $(this).parent().find(".macInvalid").css("display", "inline");
$(this).css("color", "red");
} else {
$(this).parent().find(".macInvalid").css("display", "none");
$(this).css("color", "");
}
} }
compteur = 1;
function addMacField(){
compteur++;
if(compteur > 4){
alert("Oui enfin bon on va pas en ajouter 50 non plus...");
return;
}
$("#machine_add").append($("<div></div>"));
$("#machine_add div").last().append($("<input></input>").attr("type","text").attr("id", "name_machine_input_"+compteur).attr("placeholder","nom de la machine").addClass("item_name"));
$("#machine_add div").last().append($("<input></input>").attr("type","text").attr("placeholder","adresse mac").attr("id", "mac_adress_input_"+compteur).addClass("macValidator"));
$("#machine_add div").last().append($("<span>adresse mac invalide</span>").addClass("macInvalid"));
if(compteur == 2){
$("#machine_add #name_machine_input_"+compteur).attr("name","second_machine_name");
$("#machine_add #mac_adress_input_"+compteur).attr("name","second_machine_mac");
} else if(compteur == 3){
$("#machine_add #name_machine_input_"+compteur).attr("name","third_machine_name");
$("#machine_add #mac_adress_input_"+compteur).attr("name","third_machine_mac");
} else if(compteur == 4){
$("#machine_add #name_machine_input_"+compteur).attr("name","fourth_machine_name");
$("#machine_add #mac_adress_input_"+compteur).attr("name","fourth_machine_mac");
}
}
$(document).ready(function(){
$(document).on("keyup", ".macValidator", mac_address_correcter);
});

View File

@ -5,7 +5,11 @@
<head> <head>
<link type="text/css" rel="Stylesheet" href="/css/common.css" /> <link type="text/css" rel="Stylesheet" href="/css/common.css" />
<link type="text/css" rel="Stylesheet" href="/css/show.css" /> <link type="text/css" rel="Stylesheet" href="/css/show.css" />
<script src="/js/mac_address_changer.js" /> <script src="/js/jquery-1.11.1.min.js" />
<script src="/js/mac_address_changer.js" />
<style type="text/css">
.macInvalid { color:red; display:none; }
</style>
<xi:include href="common-css-header.html" /> <xi:include href="common-css-header.html" />
</head> </head>
<body> <body>

View File

@ -27,7 +27,7 @@
</div> </div>
<div> <div>
<span class="item_name">E-mail</span> <span class="item_name">E-mail</span>
<input type="text" name="mail" value="${member_ldap.mail.first('')}" /> <input type="email" name="mail" value="${member_ldap.mail.first('')}" />
</div> </div>
<div> <div>
<span class="item_name">Téléphone</span> <span class="item_name">Téléphone</span>
@ -80,12 +80,15 @@
</py:choose> </py:choose>
</div> </div>
<div> <div>
<strong>Aide à la complétion</strong> -> vous avez un clavier <select id="osRegister"><option value="win">Windows</option><option value="mac">MacOSX</option></select>
<input type="checkbox" id="disablevalid">Disable mac validation</input>
<form action="/edit/machine/add/" method="post"> <form action="/edit/machine/add/" method="post">
<input type="text" name="name" placeholder="nom de la machine" class="item_name"/> <input type="text" name="name" placeholder="nom de la machine" class="item_name"/>
<input type="text" name="mac" onkeyup="mac_address_correcter()" id="mac_adress_input" placeholder="adresse mac" /> <input type="text" name="mac" class="macValidator" id="mac_adress_input" placeholder="adresse mac" />
<input type="hidden" name="residence" value="${residence}"/> <input type="hidden" name="residence" value="${residence}"/>
<input type="hidden" name="member_uid" value="${member_ldap.uid.first()}"/> <input type="hidden" name="member_uid" value="${member_ldap.uid.first()}"/>
<input type="submit" value="ajouter" class="button"/> <span class="macInvalid">adresse mac invalide</span>
<input type="submit" value="ajouter" class="button"/>
</form> </form>
</div> </div>
</div> </div>

View File

@ -4,7 +4,13 @@
<head> <head>
<link type="text/css" rel="Stylesheet" href="/css/common.css" /> <link type="text/css" rel="Stylesheet" href="/css/common.css" />
<link type="text/css" rel="Stylesheet" href="/css/show.css" /> <link type="text/css" rel="Stylesheet" href="/css/show.css" />
<script src="/js/mac_address_changer.js" /> <script src="/js/jquery-1.11.1.min.js" />
<script src="/js/mac_address_changer.js" />
<style type="text/css">
.macInvalid {
color:red; display:none;
}
</style>
<xi:include href="common-css-header.html" /> <xi:include href="common-css-header.html" />
</head> </head>
<body> <body>
@ -24,7 +30,7 @@
</div> </div>
<div> <div>
<span class="item_name">E-mail</span> <span class="item_name">E-mail</span>
<input type="text" name="mail" value="" /> <input type="email" name="mail" value="" />
</div> </div>
<div> <div>
<span class="item_name">Téléphone</span> <span class="item_name">Téléphone</span>
@ -45,11 +51,15 @@
</div> </div>
</div> </div>
<div class="section"> <div class="section">
<span class="section_name show_section_name">MACHINE</span> <span class="section_name show_section_name">MACHINE</span><br />
<div> <strong>Aide à la complétion</strong> -> vous avez un clavier <select id="osRegister"><option value="win">Windows</option><option value="mac">MacOSX</option></select>
<input type="checkbox" id="disablevalid">Disable mac validation</input>
<div id="machine_add">
<div> <div>
<input type="text" name="first_machine_name" placeholder="nom de la machine" class="item_name"/> <input type="text" name="first_machine_name" placeholder="nom de la machine" class="item_name"/>
<input type="text" name="first_machine_mac" onkeyup="mac_address_correcter()" id="mac_adress_input" placeholder="adresse mac" /> <input type="text" name="first_machine_mac" class="macValidator" id="mac_adress_input" placeholder="adresse mac" />
<span class="macInvalid">adresse mac invalide</span>
<a href="#" class="button" onclick="addMacField()">+</a>
</div> </div>
</div> </div>
</div> </div>