2011-10-31 15:14:05 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
from Products.Five import BrowserView
|
|
|
|
|
2011-11-01 15:15:42 +01:00
|
|
|
from themis.fields.vocabs import cmp_person
|
|
|
|
|
2011-10-31 15:14:05 +01:00
|
|
|
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):
|
2011-11-01 15:15:42 +01:00
|
|
|
return sorted([x.to_object for x in self.context.vicepresidents
|
|
|
|
if x.to_object.polgroup.to_object == polgroup], cmp_person)
|
2011-10-31 15:14:05 +01:00
|
|
|
|
|
|
|
def members_polgroups(self):
|
|
|
|
return self.list_polgroups(self.context.members)
|
|
|
|
|
|
|
|
def members_members(self, polgroup):
|
2011-11-01 15:15:42 +01:00
|
|
|
return sorted([x.to_object for x in self.context.members
|
|
|
|
if x.to_object.polgroup.to_object == polgroup], cmp_person)
|
2011-10-31 15:14:05 +01:00
|
|
|
|
|
|
|
def substitutes_polgroups(self):
|
|
|
|
return self.list_polgroups(self.context.substitutes)
|
|
|
|
|
|
|
|
def substitutes_members(self, polgroup):
|
2011-11-01 15:15:42 +01:00
|
|
|
return sorted([x.to_object for x in self.context.substitutes
|
|
|
|
if x.to_object.polgroup.to_object == polgroup], cmp_person)
|