From 809384a70bf24c128996f6af565b5d277c23ad01 Mon Sep 17 00:00:00 2001 From: Romain Beuque Date: Sun, 6 Oct 2013 23:51:45 +0200 Subject: [PATCH] ajout des features connexion/deconnexions manuelles --- Brie/brie/controllers/edit.py | 67 ++++++++++++++++++++++++++++ Brie/brie/templates/edit/member.html | 20 +++++++++ 2 files changed, 87 insertions(+) diff --git a/Brie/brie/controllers/edit.py b/Brie/brie/controllers/edit.py index eb5daf0..8ee0874 100644 --- a/Brie/brie/controllers/edit.py +++ b/Brie/brie/controllers/edit.py @@ -107,6 +107,8 @@ class MemberModificationController(AuthenticatedRestController): def __init__(self, new_show): self.show = new_show + self.disable = MemberDisableController() + self.enable = MemberEnableController() #end def """ Affiche les détails éditables du membre et de la chambre """ @@ -209,6 +211,71 @@ class MemberModificationController(AuthenticatedRestController): redirect("/edit/member/" + residence + "/" + member_uid) #end def +""" Controller REST de gestion de la deconnexion. """ +class MemberDisableController(AuthenticatedRestController): + require_group = groups_enum.admin + + """ Gestion des requêtes post sur ce controller """ + @expose() + def post(self, residence, member_uid): + residence_dn = Residences.get_dn_by_name(self.user, residence) + + # Récupération du membre et de la machine + # Note : on cherche la machine seulement sur le membre (member.dn) + member = Member.get_by_uid(self.user, residence_dn, member_uid) + if member is None: + raise Exception('membre inconnu') + #end if + + dhcps = Machine.get_dhcps(self.user, member.dn) + + machine_membre_tag = "machine_membre" # FIXME move to config + + for dhcp_item in dhcps: + if dhcp_item.uid.first() == machine_membre_tag: + dhcp_item.uid.replace(machine_membre_tag, machine_membre_tag + "_disabled") + self.user.ldap_bind.save(dhcp_item) + #end if + #end for + + # On redirige sur la page d'édition du membre + redirect("/edit/member/" + residence + "/" + member_uid) + #end def + +""" Controller REST de gestion de la reconnexion. """ +class MemberEnableController(AuthenticatedRestController): + require_group = groups_enum.admin + + """ Gestion des requêtes post sur ce controller """ + @expose() + def post(self, residence, member_uid): + residence_dn = Residences.get_dn_by_name(self.user, residence) + + # Récupération du membre et de la machine + # Note : on cherche la machine seulement sur le membre (member.dn) + member = Member.get_by_uid(self.user, residence_dn, member_uid) + if member is None: + raise Exception('membre inconnu') + #end if + + dhcps = Machine.get_dhcps(self.user, member.dn) + + machine_membre_tag = "machine_membre" # FIXME move to config + machine_membre_disabled = machine_membre_tag + "_disabled" # FIXME move to config + + for dhcp_item in dhcps: + if dhcp_item.uid.first() == machine_membre_disabled: + dhcp_item.uid.replace(machine_membre_disabled, machine_membre_tag) + self.user.ldap_bind.save(dhcp_item) + #end if + #end for + + # On redirige sur la page d'édition du membre + redirect("/edit/member/" + residence + "/" + member_uid) + #end def + + + """ Controller de gestion des machines """ class MachineController(AuthenticatedBaseController): require_group = groups_enum.admin diff --git a/Brie/brie/templates/edit/member.html b/Brie/brie/templates/edit/member.html index faad970..d7a3204 100644 --- a/Brie/brie/templates/edit/member.html +++ b/Brie/brie/templates/edit/member.html @@ -51,5 +51,25 @@ +
+
+ + +
+ déconnexion + +
+
+
+
+
+ + +
+ reconnexion + +
+
+