Added leaf pages

This commit is contained in:
Frédéric Péters 2010-06-14 15:46:42 +02:00
parent 6740fbf479
commit feda5bc18c
2 changed files with 44 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import os
import time
import calendar
import ldap
import urllib
from interfaces import IPcfAnnuaire
from zope.interface import implements
@ -23,7 +24,7 @@ class PcfAnnuaireEntry:
def __init__(self, ldap_dn, ldap_entry):
def get_attr(x):
try:
return ldap_entry.get(x)[0]
return ldap_entry.get(x)[0].strip()
except (IndexError, TypeError):
return None
self._debug_entry = ldap_entry
@ -47,6 +48,12 @@ class PcfAnnuaireEntry:
self.title = get_attr('title')
self.company = get_attr('company')
self.manager = get_attr('manager')
if self.manager:
self.manager_url = urllib.quote(self.manager)
self.manager = self.manager.split('=')[1].split(',')[0]
def __str__(self):
return urllib.quote(self.dn)
class PcfAnnuaireService:
pass
@ -165,5 +172,8 @@ class PcfAnnuaire(BaseContent):
x.service == service and x.division == cellule and x.dn not in cellule_managers]
return sorted(entries, key=get_sn)
def getPerson(self, dn):
person = [x for x in self.getEntries() if x.dn == dn][0]
return person
registerType(PcfAnnuaire)

View File

@ -21,6 +21,7 @@
tal:define="kssClassesView context/@@kss_field_decorator_view;
getKssClasses nocall:kssClassesView/getKssClassesInlineEditable;
service python:context.REQUEST.get('service');
person python:context.REQUEST.get('person');
cellule python:context.REQUEST.get('cellule');">
<div tal:replace="structure provider:plone.abovecontenttitle" />
@ -37,12 +38,14 @@
Description
</div>
<div tal:condition="python: not(service)">
<div tal:condition="python: not(service) and not(person)">
<h2>Secr&eacute;taire G&eacute;n&eacute;ral</h2>
<ul>
<li tal:repeat="entry python: [context.getSecretaireGeneral()]">
<a tal:attributes="href string:?person=${entry}">
<span tal:replace="entry/givenName">givenName</span>
<span tal:replace="entry/sn">sn</span>
</a>
</li>
</ul>
@ -58,8 +61,10 @@
<h2 tal:content="python: service">service name</h2>
<ul>
<li tal:repeat="entry python: [context.getServiceManager(service)]">
<a tal:attributes="href string:?person=${entry}">
<span tal:replace="entry/givenName">givenName</span>
<span tal:replace="entry/sn">sn</span>
</a>
</li>
</ul>
@ -69,8 +74,10 @@
<ul>
<li tal:repeat="entry python: context.getServiceNonManagers(service)">
<a tal:attributes="href string:?person=${entry}">
<span tal:replace="entry/givenName">givenName</span>
<span tal:replace="entry/sn">sn</span>
</a>
</li>
</ul>
</div>
@ -80,19 +87,44 @@
<span tal:content="python: cellule">cellule name</span></h2>
<ul>
<li tal:repeat="entry python: context.getCelluleManagers(service, cellule)">
<a tal:attributes="href string:?person=${entry}">
<span tal:replace="entry/givenName">givenName</span>
<span tal:replace="entry/sn">sn</span>
</a>
</li>
</ul>
<ul>
<li tal:repeat="entry python: context.getCellulePeople(service, cellule)">
<a tal:attributes="href string:?person=${entry}">
<span tal:replace="entry/givenName">givenName</span>
<span tal:replace="entry/sn">sn</span>
</a>
</li>
</ul>
</div>
<div tal:condition="python: person">
<div tal:define="entry python: context.getPerson(person)">
<h2><span tal:replace="entry/givenName">givenName</span>
<span tal:replace="entry/sn">sn</span></h2>
<ul>
<li>Téléphone(s) : <span tal:repeat="telephoneNumber entry/telephoneNumbers">
<span tal:replace="telephoneNumber">phoneNumber</span>
</span></li>
<li tal:condition="entry/shortTelephoneNumber">Téléphone (abrégé) : <span tal:replace="entry/shortTelephoneNumber"></span></li>
<li tal:condition="entry/mobile">GSM : <span tal:replace="entry/mobile"></span></li>
<li tal:condition="entry/building">Bâtiment : <span tal:replace="entry/building"></span></li>
<li tal:condition="entry/floor">Étage : <span tal:replace="entry/floor"></span></li>
<li tal:condition="entry/office">Bureau : <span tal:replace="entry/office"></span></li>
<li tal:condition="entry/fax">Fax : <span tal:replace="entry/fax"></span></li>
<li tal:condition="entry/title">Titre : <span tal:replace="entry/title"></span></li>
<li tal:condition="entry/email">Courriel : <a tal:attributes="href string:mailto:${entry/email}" tal:content="entry/email"></a></li>
<li tal:condition="entry/service">Service : <span tal:replace="entry/service"></span></li>
<li tal:condition="entry/manager">Chef de service : <a tal:attributes="href string:?person=${entry/manager}" tal:content="entry/manager"></a></li>
</ul>
</div>
</div>
<div tal:replace="structure provider:plone.belowcontentbody" />
</tal:main-macro>