ré-introduction du changement de mot de passe wifi en plugin
This commit is contained in:
parent
4f9ea189c9
commit
82f76928e1
@ -3,7 +3,7 @@
|
|||||||
from tg import session
|
from tg import session
|
||||||
from tg.controllers import redirect
|
from tg.controllers import redirect
|
||||||
from tg.decorators import expose, validate
|
from tg.decorators import expose, validate
|
||||||
from brie.config import ldap_config
|
from brie.config import ldap_config, groups_enum
|
||||||
from brie.lib.ldap_helper import *
|
from brie.lib.ldap_helper import *
|
||||||
from brie.lib.aurore_helper import *
|
from brie.lib.aurore_helper import *
|
||||||
from brie.lib.plugins import *
|
from brie.lib.plugins import *
|
||||||
@ -16,6 +16,7 @@ from operator import itemgetter
|
|||||||
|
|
||||||
""" Controller d'affichage de details de membres, chambres et interfaces """
|
""" Controller d'affichage de details de membres, chambres et interfaces """
|
||||||
class ShowController(AuthenticatedBaseController):
|
class ShowController(AuthenticatedBaseController):
|
||||||
|
require_group = groups_enum.admin
|
||||||
|
|
||||||
@expose("brie.templates.show.error")
|
@expose("brie.templates.show.error")
|
||||||
def error_no_entry(self):
|
def error_no_entry(self):
|
||||||
|
@ -113,7 +113,7 @@ class Wifi(object):
|
|||||||
#end def
|
#end def
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_by_dn(user_session, dn):
|
def get_by_member_dn(user_session, dn):
|
||||||
return user_session.ldap_bind.search_dn("cn=wifi," + dn)
|
return user_session.ldap_bind.search_dn("cn=wifi," + dn)
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
from tg.decorators import expose
|
from tg.decorators import expose
|
||||||
from tg.controllers import redirect
|
from tg.controllers import redirect
|
||||||
|
|
||||||
from brie.config import ldap_config
|
from brie.config import ldap_config, groups_enum
|
||||||
from brie.lib.ldap_helper import *
|
from brie.lib.ldap_helper import *
|
||||||
from brie.lib.aurore_helper import *
|
from brie.lib.aurore_helper import *
|
||||||
from brie.model.ldap import *
|
from brie.model.ldap import *
|
||||||
|
|
||||||
|
from brie.model.ldap import Wifi as WifiModel
|
||||||
|
|
||||||
from brie.controllers import auth
|
from brie.controllers import auth
|
||||||
from brie.controllers.auth import AuthenticatedBaseController, AuthenticatedRestController
|
from brie.controllers.auth import AuthenticatedBaseController, AuthenticatedRestController
|
||||||
|
|
||||||
@ -16,21 +18,56 @@ class Wifi:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
@expose("brie.plugins.wifi.show")
|
@expose("brie.plugins.wifi.show")
|
||||||
def show(models):
|
def show(models):
|
||||||
|
member = models["member_ldap"]
|
||||||
|
user = models["user"]
|
||||||
|
|
||||||
|
wifi = WifiModel.get_by_member_dn(user, member.dn)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"activated" : str("Todo")
|
"activated" : str(wifi is not None)
|
||||||
}
|
}
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
#end class
|
#end class
|
||||||
|
|
||||||
class DirectController(AuthenticatedRestController):
|
class DirectController(AuthenticatedRestController):
|
||||||
@expose("")
|
require_group = groups_enum.respsalleinfo
|
||||||
|
|
||||||
|
@expose("brie.plugins.wifi.edit")
|
||||||
def get(self, residence, member_uid):
|
def get(self, residence, member_uid):
|
||||||
redirect("/show/member/" + residence + "/" + member_uid)
|
residence_dn = Residences.get_dn_by_name(self.user, residence)
|
||||||
|
member = Member.get_by_uid(self.user, residence_dn, member_uid)
|
||||||
|
if member is None:
|
||||||
|
raise Exception("invalid member uid")
|
||||||
|
|
||||||
|
return {
|
||||||
|
"user" : self.user,
|
||||||
|
"residence" : residence,
|
||||||
|
"member_ldap" : member
|
||||||
|
}
|
||||||
|
|
||||||
#end def
|
#end def
|
||||||
|
|
||||||
|
|
||||||
@expose("")
|
@expose("")
|
||||||
def post(self, residence, member_uid):
|
def post(self, residence, member_uid, password):
|
||||||
|
residence_dn = Residences.get_dn_by_name(self.user, residence)
|
||||||
|
member = Member.get_by_uid(self.user, residence_dn, member_uid)
|
||||||
|
if member is None:
|
||||||
|
raise Exception("invalid member uid")
|
||||||
|
|
||||||
|
|
||||||
|
wifi = WifiModel.get_by_member_dn(self.user, member.dn)
|
||||||
|
|
||||||
|
if wifi is None:
|
||||||
|
wifi_dn = "cn=wifi," + member.dn
|
||||||
|
wifi_attr = WifiModel.entry_attr(password)
|
||||||
|
self.user.ldap_bind.add_entry(wifi_dn, wifi_attr)
|
||||||
|
else:
|
||||||
|
wifi.userPassword.replace(wifi.userPassword.first(), password)
|
||||||
|
self.user.ldap_bind.save(wifi)
|
||||||
|
#end
|
||||||
|
|
||||||
redirect("/show/member/" + residence + "/" + member_uid)
|
redirect("/show/member/" + residence + "/" + member_uid)
|
||||||
#end def
|
#end def
|
||||||
#end class
|
#end class
|
||||||
|
@ -1,26 +1,31 @@
|
|||||||
<html
|
<html
|
||||||
xmlns:py="http://genshi.edgewall.org/"
|
xmlns:py="http://genshi.edgewall.org/"
|
||||||
xmlns:xi="http://www.w3.org/2001/XInclude">
|
xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||||
<xi:include href="member_room_interface_edit_views.html" />
|
<xi:include href="../../templates/edit/member_room_interface_edit_views.html" />
|
||||||
<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" />
|
||||||
<link type="text/css" rel="Stylesheet" href="/css/edit.css" />
|
<link type="text/css" rel="Stylesheet" href="/css/edit.css" />
|
||||||
|
<xi:include href="common-css-header.html" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
${edit_banner()}
|
<xi:include href="navbar.html" />
|
||||||
${back_show("member", member_ldap.uid.first())}
|
${back_show("member", member_ldap.uid.first())}
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<span class="section_name show_section_name">WIFI :: ${member_ldap.cn.first()}</span>
|
<span class="section_name show_section_name">WIFI :: ${member_ldap.cn.first()}</span>
|
||||||
<form action="/edit/wifi/${member_ldap.uid.first()}" method="POST">
|
<form action="/plugins/wifi/${residence}/${member_ldap.uid.first()}" method="POST">
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<input type="hidden" name="uid" value="${member_ldap.uid.first()}" />
|
<input type="hidden" name="residence" value="${residence}" />
|
||||||
<span class="item_name">Mot de passe</span>
|
<input type="hidden" name="member_uid" value="${member_ldap.uid.first()}" />
|
||||||
|
<span class="item_name">Nouveau mot de passe</span>
|
||||||
<input type="password" name="password" />
|
<input type="password" name="password" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<span class="item_name"></span>
|
||||||
<input type="submit" value="ENREGISTRER" class="button"/>
|
<input type="submit" value="ENREGISTRER" class="button"/>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
@ -10,7 +10,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span class="item_name">Mot de passe</span>
|
<span class="item_name">Mot de passe</span>
|
||||||
<span><a href="/plugins/wifi/edit/${residence}/${member_ldap.uid.first()}" class="link_button">changer</a></span>
|
<span><a href="/plugins/wifi/${residence}/${member_ldap.uid.first()}" class="link_button">changer</a></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</html>
|
</html>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span class="item_name">Extra payés</span>
|
<span class="item_name">Extra payés</span>
|
||||||
<span py:for="extra in extras">${extra.description.first()} (${extra.get("x-amountPaid").first()} €) ; </span>
|
<span py:for="extra in extras" title="${extra.get('x-action-user-info').first()} / ${extra.get('x-time').first()}">${extra.description.first()} (${extra.get("x-amountPaid").first()} €) ; </span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user