From 74a4c9a256131db8adb55ce537c1574a62088b68 Mon Sep 17 00:00:00 2001 From: Romain Beuque Date: Sat, 20 Sep 2014 13:17:58 +0200 Subject: [PATCH] =?UTF-8?q?=20[registration]=20ajour=20de=20plusieurs=20ad?= =?UTF-8?q?resses=20mac=20+=20saisie=20simplifi=C3=A9e=20des=20adresses=20?= =?UTF-8?q?mac=20adapt=C3=A9e=20pour=20MacOS=20avec=20tous=20les=20fichier?= =?UTF-8?q?s=20cette=20fois-=C3=A7i?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Brie/brie/controllers/registration.py | 36 ++++---- Brie/brie/public/css/form-signin.css | 2 +- Brie/brie/public/js/mac_address_changer.js | 82 +++++++++++++------ Brie/brie/templates/edit/member.html | 6 +- .../member_room_interface_edit_views.html | 15 ++-- Brie/brie/templates/registration/index.html | 22 +++-- 6 files changed, 108 insertions(+), 55 deletions(-) diff --git a/Brie/brie/controllers/registration.py b/Brie/brie/controllers/registration.py index 8a287c0..3be3fa6 100644 --- a/Brie/brie/controllers/registration.py +++ b/Brie/brie/controllers/registration.py @@ -159,7 +159,10 @@ class NewRegistrationController(AuthenticatedRestController): @expose() def post(self, residence, sn, givenName, mail, phone, 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 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) #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: + 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 != "": self.administration_controller.groups.add_member.post(group_cn, member.dn, go_redirect = False) #end if except: - trigerErreur = True - - if trigerErreur: redirect("/registration/error/" + member_uid) - + #end trycatch redirect("/registration/") #end def diff --git a/Brie/brie/public/css/form-signin.css b/Brie/brie/public/css/form-signin.css index aa257c0..d2c5e48 100644 --- a/Brie/brie/public/css/form-signin.css +++ b/Brie/brie/public/css/form-signin.css @@ -23,7 +23,7 @@ } -input[type="text"],input[type="password"] +input[type="text"],input[type="password"],input[type=email] { height: 28px; } diff --git a/Brie/brie/public/js/mac_address_changer.js b/Brie/brie/public/js/mac_address_changer.js index 12bb718..8ce0d3a 100644 --- a/Brie/brie/public/js/mac_address_changer.js +++ b/Brie/brie/public/js/mac_address_changer.js @@ -1,36 +1,64 @@ function mac_address_correcter(event){ - var valeur = document.getElementById("mac_adress_input").value; - console.log(document.getElementById("mac_adress_input").value); - var regex = /&/g; - valeur = valeur.replace(regex, "1"); - var regex = /é/g; - valeur = valeur.replace(regex, "2"); - var regex = /"/g; - valeur = valeur.replace(regex, "3"); - var regex = /'/g; - valeur = valeur.replace(regex, "4"); - var regex = /\(/g; - valeur = valeur.replace(regex, "5"); - var regex = /-/g; - valeur = valeur.replace(regex, "6"); - var regex = /è/g; - valeur = valeur.replace(regex, "7"); - var regex = /_/g; - valeur = valeur.replace(regex, "8"); - var regex = /ç/g; - valeur = valeur.replace(regex, "9"); - var regex = /à/g; - valeur = valeur.replace(regex, "0"); + if($("#disablevalid:checked").length == 1){ return; } + //si on tape sur backspace ou delete + if(event.keyCode == 8 || event.keyCode == 46) { return; } + var valeur = $(this).val(); + var os = $("#osRegister").val(); + console.log(valeur); + var regex = Array(); + regex['win'] = Array(/&/g, /é/g, /"/g, /'/g, /\(/g, /-/g, /è/g, /_/g, /ç/g, /à/g); + regex['mac'] = Array(/&/g, /é/g, /"/g, /'/g, /\(/g, /§/g, /è/g, /\!/g, /ç/g, /à/g); + valeur = valeur.replace(regex[os][0], "1"); + valeur = valeur.replace(regex[os][1], "2"); + valeur = valeur.replace(regex[os][2], "3"); + valeur = valeur.replace(regex[os][3], "4"); + valeur = valeur.replace(regex[os][4], "5"); + valeur = valeur.replace(regex[os][5], "6"); + valeur = valeur.replace(regex[os][6], "7"); + valeur = valeur.replace(regex[os][7], "8"); + valeur = valeur.replace(regex[os][8], "9"); + valeur = valeur.replace(regex[os][9], "0"); if(valeur.length == 2 || valeur.length == 5 || valeur.length == 8 || valeur.length == 11 || valeur.length == 14){ valeur = valeur + ":"; - document.getElementById("mac_adress_input").value = valeur; + $(this).val(valeur); } var regex = /::/g; valeur = valeur.replace(regex, ":"); - if(document.getElementById("mac_adress_input").value != valeur){ - document.getElementById("mac_adress_input").value = valeur; + if($(this).val() != valeur){ + $(this).val(valeur); } var regex = /[^A-Fa-f0-9:]/gi; - if(valeur.search(regex) != -1) - alert("ERREUR"); + if(valeur.search(regex) != -1 || valeur.length > 17){ + $(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($("
")); + $("#machine_add div").last().append($("").attr("type","text").attr("id", "name_machine_input_"+compteur).attr("placeholder","nom de la machine").addClass("item_name")); + $("#machine_add div").last().append($("").attr("type","text").attr("placeholder","adresse mac").attr("id", "mac_adress_input_"+compteur).addClass("macValidator")); + $("#machine_add div").last().append($("adresse mac invalide").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); +}); diff --git a/Brie/brie/templates/edit/member.html b/Brie/brie/templates/edit/member.html index 6fb77a7..d1e605c 100644 --- a/Brie/brie/templates/edit/member.html +++ b/Brie/brie/templates/edit/member.html @@ -5,7 +5,11 @@ -