ajout des recherches sur mac et ip
This commit is contained in:
parent
acb77016f2
commit
9723d198d1
@ -76,6 +76,83 @@ class SearchController(AuthenticatedBaseController):
|
||||
#end def
|
||||
|
||||
|
||||
@expose("brie.templates.search.member")
|
||||
def mac(self, residence, mac):
|
||||
residence_dn = Residences.get_dn_by_name(self.user, residence)
|
||||
machine = Machine.get_dhcp_by_mac(self.user, residence_dn, mac)
|
||||
|
||||
if machine is None:
|
||||
return self.error_no_entry()
|
||||
|
||||
machine = machine.dn.split(',')
|
||||
|
||||
i = 0
|
||||
member_dn = ""
|
||||
for sub in machine:
|
||||
if i >= 3:
|
||||
if member_dn != "":
|
||||
member_dn += ","
|
||||
#end if
|
||||
member_dn += sub
|
||||
#end if
|
||||
i += 1
|
||||
#end for
|
||||
|
||||
member = Member.get_by_dn(self.user, member_dn)
|
||||
|
||||
if member is None:
|
||||
return self.error_no_entry()
|
||||
#end if
|
||||
|
||||
redirect("/show/member/"+ residence +"/" + member.uid.first())
|
||||
#end def
|
||||
|
||||
|
||||
@expose("brie.templates.search.ip")
|
||||
def ip(self, residence, ip):
|
||||
residence_dn = Residences.get_dn_by_name(self.user, residence)
|
||||
machines = Machine.get_dns_by_ip(self.user, residence_dn, ip)
|
||||
|
||||
if len(machines) == 0:
|
||||
return self.error_no_entry()
|
||||
|
||||
results = []
|
||||
|
||||
for machine in machines:
|
||||
membre_dn = machine.dn.split(',')
|
||||
|
||||
i = 0
|
||||
member_dn = ""
|
||||
for sub in membre_dn:
|
||||
if i >= 3:
|
||||
if member_dn != "":
|
||||
member_dn += ","
|
||||
#end if
|
||||
member_dn += sub
|
||||
#end if
|
||||
i += 1
|
||||
#end for
|
||||
|
||||
member = Member.get_by_dn(self.user, member_dn)
|
||||
if member is None:
|
||||
return self.error_no_entry()
|
||||
#end if
|
||||
|
||||
if len(machines) == 1:
|
||||
redirect("/show/member/"+ residence +"/"+ member.uid.first())
|
||||
#end if
|
||||
|
||||
results.append((member, machine))
|
||||
#end for
|
||||
|
||||
return {
|
||||
"residence" : residence,
|
||||
"user" : self.user,
|
||||
"results" : results
|
||||
}
|
||||
#end def
|
||||
|
||||
|
||||
@expose("brie.templates.search.member_global")
|
||||
def member_global(self, myresidence, name):
|
||||
residences = Residences.get_residences(self.user)
|
||||
|
@ -221,6 +221,11 @@ class Machine(object):
|
||||
return user_session.ldap_bind.search_first(machine_dn, "(objectClass=dlzAbstractRecord)")
|
||||
#end def
|
||||
|
||||
@staticmethod
|
||||
def get_dns_by_ip(user_session, search_dn, ip):
|
||||
return user_session.ldap_bind.search(search_dn, "(dlzData="+ ip +")")
|
||||
#end def
|
||||
|
||||
@staticmethod
|
||||
def get_dhcps(user_session, machine_dn):
|
||||
return user_session.ldap_bind.search(machine_dn, "(objectClass=dhcpHost)")
|
||||
|
@ -55,6 +55,22 @@
|
||||
<input type="submit" value="Search global" class="button"/>
|
||||
</form>
|
||||
</div>
|
||||
<div class="section">
|
||||
<span class="section_name show_section_name">Adresse mac</span>
|
||||
<form action="/search/mac/" method="post" class="inline_block">
|
||||
<input type="hidden" name="residence" value="${residence}"/>
|
||||
<input type="text" name="mac"/>
|
||||
<input type="submit" value="Search" class="button"/>
|
||||
</form>
|
||||
</div>
|
||||
<div class="section">
|
||||
<span class="section_name show_section_name">Adresse IP</span>
|
||||
<form action="/search/ip/" method="post" class="inline_block">
|
||||
<input type="hidden" name="residence" value="${residence}"/>
|
||||
<input type="text" name="ip"/>
|
||||
<input type="submit" value="Search" class="button"/>
|
||||
</form>
|
||||
</div>
|
||||
<div class="section">
|
||||
<form action="/edit/member/disconnectall/" method="post" class="inline_block">
|
||||
<input type="hidden" name="residence" value="${residence}"/>
|
||||
|
22
Brie/brie/templates/search/ip.html
Normal file
22
Brie/brie/templates/search/ip.html
Normal file
@ -0,0 +1,22 @@
|
||||
<html
|
||||
xmlns:py="http://genshi.edgewall.org/"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<head>
|
||||
<link type="text/css" rel="Stylesheet" href="/css/common.css" />
|
||||
<link type="text/css" rel="Stylesheet" href="/css/rooms.css" />
|
||||
<xi:include href="common-css-header.html" />
|
||||
</head>
|
||||
<body>
|
||||
<xi:include href="navbar.html" />
|
||||
<table class="table table-hover">
|
||||
<tr>
|
||||
<th>membre</th>
|
||||
<th>machine name</th>
|
||||
</tr>
|
||||
<tr py:for="member, machine in results">
|
||||
<td><a href="/show/member/${residence}/${member.uid.first()}">${member.cn.first()}</a></td>
|
||||
<td>${machine.dlzHostName.first()} (${machine.dlzData.first()})</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
34
Brie/brie/templates/search/member_global.html
Normal file
34
Brie/brie/templates/search/member_global.html
Normal file
@ -0,0 +1,34 @@
|
||||
<html
|
||||
xmlns:py="http://genshi.edgewall.org/"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<head>
|
||||
<link type="text/css" rel="Stylesheet" href="/css/common.css" />
|
||||
<link type="text/css" rel="Stylesheet" href="/css/rooms.css" />
|
||||
<xi:include href="common-css-header.html" />
|
||||
</head>
|
||||
<body>
|
||||
<xi:include href="navbar.html" />
|
||||
<table class="table table-hover">
|
||||
<tr>
|
||||
<th>membre</th>
|
||||
<th>résidence</th>
|
||||
<th>chambre</th>
|
||||
<th>déménager</th>
|
||||
</tr>
|
||||
<tr py:for="member, room, mresidence in members_rooms">
|
||||
<td><a href="/show/member/${mresidence}/${member.uid.first()}">${member.cn.first()}</a></td>
|
||||
<td>${mresidence}</td>
|
||||
<py:choose test="room">
|
||||
<td py:when="None">sdf</td>
|
||||
<td py:otherwise=""><a href="/show/room/${mresidence}/${room.uid.first()}">${room.cn.first()}</a></td>
|
||||
</py:choose>
|
||||
<td>
|
||||
<form action="/members/demenageResidence/" style="margin-bottom:0px" method="post" class="inline_block">
|
||||
<input type="hidden" name="member_dn" value="${member.dn}"/>
|
||||
<input type="submit" value="Move" class="button"/>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user