sync commission secretariat

This commit is contained in:
Frédéric Péters 2011-11-23 14:36:44 +01:00
parent 527ed6a3b7
commit 94ba9733d1
1 changed files with 29 additions and 0 deletions

View File

@ -20,6 +20,7 @@ from zope import component
from zope.app.intid.interfaces import IIntIds
from z3c.relationfield import RelationValue
from zope.i18n.locales import locales
from plone.app.textfield.value import RichTextValue
import transaction
@ -698,6 +699,34 @@ class SyncFromPcfDbView(BrowserView):
firstname, lastname, 'S_MINISTRE')))
minist_cursor.close()
secr_cursor = self.db_connection.cursor()
secr_cursor.execute('''SELECT titre, sexe, nom, prenom, adjoint, email, attrib
FROM t_comsecr
WHERE comid = %(id)s
ORDER BY adjoint, nom''', {'id': com_id})
s = ['<ul>\n']
while True:
row = secr_cursor.fetchone()
if row is None:
break
titre, sexe, nom, prenom, adjoint, email, attrib = row
s.append('<li><a href="mailto:%s">%s %s %s</a>' % (
email.replace('@', ' arobase ').replace('.', ' point '),
titre, prenom, nom))
if adjoint:
if sexe == 'M':
s.append(u' (adjoint)')
else:
s.append(u' (adjointe)')
if attrib:
s.append(u' (%s)' % attrib)
s.append('</li>\n')
s.append('</ul>\n')
object.secretariat = RichTextValue(raw=''.join(s),
mimeType='text/html',
outputMimeType='text/x-html-safe')
secr_cursor.close()
notify(ObjectModifiedEvent(object))
if object.active:
self.publish(object)