From 224fad97e6c685aba0a3861df4da3664845d661c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 31 Oct 2011 15:14:05 +0100 Subject: [PATCH] add commission view --- tabellio/pfbviews/commission.pt | 83 ++++++++++++++++++++++++++++++++ tabellio/pfbviews/commission.py | 46 ++++++++++++++++++ tabellio/pfbviews/configure.zcml | 8 +++ 3 files changed, 137 insertions(+) create mode 100644 tabellio/pfbviews/commission.pt create mode 100644 tabellio/pfbviews/commission.py diff --git a/tabellio/pfbviews/commission.pt b/tabellio/pfbviews/commission.pt new file mode 100644 index 0000000..2f68f74 --- /dev/null +++ b/tabellio/pfbviews/commission.pt @@ -0,0 +1,83 @@ + + + + + + +
+

Les commissions

+
+ +
+ +

Title

+ +

Président(e)

+ +
+ + +
+ +
+

Vice Président(e)s

+ +
+ + +
+
+ +
+

Membres effectifs/ves

+ +
+ + +
+
+ +
+

Membres suppléant(e)s

+ +
+ + +
+
+ +
+ + + + + + + + diff --git a/tabellio/pfbviews/commission.py b/tabellio/pfbviews/commission.py new file mode 100644 index 0000000..666abca --- /dev/null +++ b/tabellio/pfbviews/commission.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- + +from Products.Five import BrowserView + +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 [x.to_object for x in self.context.vicepresidents + if x.to_object.polgroup.to_object == polgroup] + + def members_polgroups(self): + return self.list_polgroups(self.context.members) + + def members_members(self, polgroup): + return [x.to_object for x in self.context.members + if x.to_object.polgroup.to_object == polgroup] + + def substitutes_polgroups(self): + return self.list_polgroups(self.context.substitutes) + + def substitutes_members(self, polgroup): + return [x.to_object for x in self.context.substitutes + if x.to_object.polgroup.to_object == polgroup] diff --git a/tabellio/pfbviews/configure.zcml b/tabellio/pfbviews/configure.zcml index 971e5da..578553b 100644 --- a/tabellio/pfbviews/configure.zcml +++ b/tabellio/pfbviews/configure.zcml @@ -17,4 +17,12 @@ permission="zope2.View" /> + +