From cde55919ba2d4dd9a8159c0aa3263127abde0046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 16 Nov 2011 15:52:27 +0100 Subject: [PATCH] add template for commissions, listing recent meetings (#911) --- tabellio/pcfviews/commission.pt | 103 +++++++++++++++++++++++++++++++ tabellio/pcfviews/commission.py | 71 +++++++++++++++++++++ tabellio/pcfviews/configure.zcml | 8 +++ 3 files changed, 182 insertions(+) create mode 100644 tabellio/pcfviews/commission.pt create mode 100644 tabellio/pcfviews/commission.py diff --git a/tabellio/pcfviews/commission.pt b/tabellio/pcfviews/commission.pt new file mode 100644 index 0000000..00945cf --- /dev/null +++ b/tabellio/pcfviews/commission.pt @@ -0,0 +1,103 @@ + + + + + + +
+

Title

+
+ +
+ +
+

Compétences

+
    +
  • item
  • +
+
+ +
+

Ministre compétent :

+

Ministres compétents :

+
    +
  • item
  • +
+
+ +

Composition

+ +

Président(e)

+ +
+ + +
+ +
+

Vice Président(e)s

+ +
+ + +
+
+ +
+

Membres effectifs/ves

+ +
+ + +
+
+ +
+

Membres suppléant(e)s

+ +
+ + +
+
+ + +

Dernières réunions

+ +
+ +
+ + + + + + diff --git a/tabellio/pcfviews/commission.py b/tabellio/pcfviews/commission.py new file mode 100644 index 0000000..cde3cc6 --- /dev/null +++ b/tabellio/pcfviews/commission.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- + +from zope import component +from zc.relation.interfaces import ICatalog +from zope.app.intid.interfaces import IIntIds +from Products.CMFCore.utils import getToolByName + +from Products.Five import BrowserView + +from themis.fields.vocabs import cmp_person + +class View(BrowserView): + def presidence_polgroups(self): + return [self.context.president.to_object.polgroup.to_object] + + def presidence_members(self, polgroup): + return [self.context.president.to_object] + + def list_polgroups(self, list): + d = {} + polgroups = {} + for member in list: + polgroup = member.to_object.polgroup.to_object + polgroup_id = polgroup.id + polgroups[polgroup.id] = polgroup + if not polgroup_id in d: + d[polgroup_id] = 0 + d[polgroup_id] = d[polgroup_id] + 1 + items = d.items() + items.sort(lambda x,y: cmp(x[1], y[1])) + items.reverse() + return [polgroups.get(x[0]) for x in items] + + def vicepresidence_polgroups(self): + return self.list_polgroups(self.context.vicepresidents) + + def vicepresidence_members(self, polgroup): + return sorted([x.to_object for x in self.context.vicepresidents + if x.to_object.polgroup.to_object == polgroup], cmp_person) + + def members_polgroups(self): + return self.list_polgroups(self.context.members) + + def members_members(self, polgroup): + return sorted([x.to_object for x in self.context.members + if x.to_object.polgroup.to_object == polgroup], cmp_person) + + def substitutes_polgroups(self): + return self.list_polgroups(self.context.substitutes) + + def substitutes_members(self, polgroup): + return sorted([x.to_object for x in self.context.substitutes + if x.to_object.polgroup.to_object == polgroup], cmp_person) + + def get_meetings(self): + intids = component.getUtility(IIntIds) + catalog = component.getUtility(ICatalog) + try: + com_intid = intids.getId(self.context) + except KeyError: + intids.register(self.context) + com_intid = intids.get(self.context) + # objects created from relations do not have a working absolute_url() + # method; so we get ids and go through the catalog do fetch appropriate + # brains. + meeting_ids = [x.from_object.id for x in catalog.findRelations( + {'to_id': com_intid, 'from_attribute': 'commission'})] + portal_catalog = getToolByName(self.context, 'portal_catalog') + return portal_catalog(portal_type='tabellio.agenda.comevent', + id=meeting_ids, + sort_on='start', sort_order='descending')[:10] diff --git a/tabellio/pcfviews/configure.zcml b/tabellio/pcfviews/configure.zcml index bafd9f7..8367174 100644 --- a/tabellio/pcfviews/configure.zcml +++ b/tabellio/pcfviews/configure.zcml @@ -44,6 +44,14 @@ permission="zope2.View" /> + +