From 67cd42b6bf18b274c49b2fc4eae01f4a7f1f95bc Mon Sep 17 00:00:00 2001 From: Yohan Bataille Date: Wed, 29 Jan 2014 20:29:34 +0100 Subject: [PATCH] =?UTF-8?q?Syst=C3=A8me=20de=20d=C3=A9connexion/reconnexio?= =?UTF-8?q?n=20globale=20pour=20les=20AGs=20fonctionnel.=20Nouveau=20group?= =?UTF-8?q?e=20pour=20les=20membres=20exempt=C3=A9s=20de=20d=C3=A9connexio?= =?UTF-8?q?n=20globale.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Brie/brie/config/groups_enum.py | 1 + Brie/brie/controllers/edit.py | 70 ++++++++++++++++++--------------- Brie/brie/templates/index.html | 7 +++- 3 files changed, 44 insertions(+), 34 deletions(-) diff --git a/Brie/brie/config/groups_enum.py b/Brie/brie/config/groups_enum.py index d924623..d968240 100644 --- a/Brie/brie/config/groups_enum.py +++ b/Brie/brie/config/groups_enum.py @@ -5,3 +5,4 @@ admin = "admin" membreca = "membreca" tresorier = "tresorier" respsalleinfo = "respsalleinfo" +exemptdecoglobale = "exemptdecoglobale" diff --git a/Brie/brie/controllers/edit.py b/Brie/brie/controllers/edit.py index 574c271..2578f12 100644 --- a/Brie/brie/controllers/edit.py +++ b/Brie/brie/controllers/edit.py @@ -113,6 +113,8 @@ class MemberModificationController(AuthenticatedRestController): self.show = new_show self.disable = MemberDisableController() self.enable = MemberEnableController() + self.disconnectall = AllMembersDisableController() + self.reconnectall = AllMembersEnableController() #end def """ Affiche les détails éditables du membre et de la chambre """ @@ -793,13 +795,12 @@ class RoomChangeMemberController(AuthenticatedRestController): #end def #end def -# TODO : """ Controller REST de gestion de la deconnexion globale. """ class AllMembersDisableController(AuthenticatedRestController): require_group = groups_enum.admin """ Gestion des requêtes post sur ce controller """ - @expose() + @expose("brie.templates.index") def post(self, residence): residence_dn = Residences.get_dn_by_name(self.user, residence) @@ -807,56 +808,61 @@ class AllMembersDisableController(AuthenticatedRestController): # Note : on cherche la machine seulement sur le membre (member.dn) members = Member.get_all(self.user, residence_dn) for member in members: - member = Member.get_by_uid(self.user, residence_dn, member_uid) if member is None: raise Exception('membre inconnu') #end if + groups_of_user = Groupes.get_by_user_dn(self.user, residence_dn, member.dn) + if "exemptdecoglobale" not in groups_of_user: + dhcps = Machine.get_dhcps(self.user, member.dn) + + machine_membre_tag = "machine_membre" # FIXME move to config - 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 + #end if + #end for - 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) + # On redirige sur la page d'accueil + redirect("/") #end def -# TODO : """ Controller REST de gestion de la reconnexion globale. """ class AllMembersEnableController(AuthenticatedRestController): require_group = groups_enum.admin """ Gestion des requêtes post sur ce controller """ - @expose() + @expose("brie.templates.index") def post(self, residence): 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 + members = Member.get_all(self.user, residence_dn) + for member in members: + if member is None: + raise Exception('membre inconnu') + #end if + # On ne reconnecte que les membres ayant payé leur cotisation. + if CotisationComputes.is_cotisation_paid(member, self.user, residence_dn): + 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 - 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) + 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 #end if #end for - # On redirige sur la page d'édition du membre - redirect("/edit/member/" + residence + "/" + member_uid) + # On redirige sur la page d'accueil + redirect("/") #end def diff --git a/Brie/brie/templates/index.html b/Brie/brie/templates/index.html index b430fd7..a720ca1 100644 --- a/Brie/brie/templates/index.html +++ b/Brie/brie/templates/index.html @@ -37,12 +37,15 @@ -
-
+
+
+ + +