documents dont le deputé est orateur ou reporteur affichés

This commit is contained in:
Serghei Mihai 2013-11-13 11:43:45 +01:00
parent 3974dee99f
commit f0199bab47
No known key found for this signature in database
GPG Key ID: 76D1C964BF2FA1AF
2 changed files with 48 additions and 1 deletions

View File

@ -107,6 +107,8 @@
<a tal:attributes="href actobj/canonical_path"><span tal:content="actobj/title"/></a>
<span tal:condition="python: activity[1] == 'participant'">(en tant que participant)</span>
<span tal:condition="python: activity[1] == 'reporter'">(en tant que rapporteur)</span>
<span tal:condition="python: activity[1] == 'speaker'">(en tant qu'orateur)</span>
</li>
</tal:block>
</tal:block>

View File

@ -136,6 +136,44 @@ class View(BrowserView, Cached):
self._activity_as_participant = activity
return activity
_activity_as_reporter = None
def get_activity_as_reporter(self):
if self._activity_as_reporter is not None:
return self._activity_as_reporter
intids = component.getUtility(IIntIds)
catalog = component.getUtility(ICatalog)
try:
reporter_intid = intids.getId(self.context)
except KeyError:
intids.register(self.context)
reporter_intid = initds.get(self.context)
reports = [x.from_object for x in catalog.findRelations({
'to_id': reporter_intid,
'from_attribute': 'reporters'})]
reports = [x for x in reports if hasattr(x, 'date')]
self._activity_as_reporter = reports
return reports
_activity_as_speaker = None
def get_activity_as_speaker(self):
if self._activity_as_speaker is not None:
return self._activity_as_speaker
intids = component.getUtility(IIntIds)
catalog = component.getUtility(ICatalog)
try:
speaker_intid = intids.getId(self.context)
except KeyError:
intids.register(self.context)
speaker_intid = intids.get(self.context)
speeches = [x.from_object for x in catalog.findRelations({
'to_id': speaker_intid,
'from_attribute': 'speakers'})]
speeches = [x for x in speeches if hasattr(x, 'date')]
self._activity_as_speaker = speeches
return speeches
def sessions_with_activity(self):
sessions_dict = {}
@ -143,15 +181,22 @@ class View(BrowserView, Cached):
sessions_dict[activity.session] = True
for activity in self.get_activity_as_participant():
sessions_dict[activity.session] = True
for activity in self.get_activity_as_speaker():
sessions_dict[activity.session] = True
for activity in self.get_activity_as_reporter():
sessions_dict[activity.session] = True
sessions = []
for session in tabellio.config.utils.get_sessions():
if session in sessions_dict:
sessions.append(session)
return sessions
def activity(self, session=None):
activity = [(x, 'author') for x in self.get_activity_as_author()] + \
[(x, 'participant') for x in self.get_activity_as_participant()]
[(x, 'participant') for x in self.get_activity_as_participant()] + \
[(x, 'reporter') for x in self.get_activity_as_reporter()] + \
[(x, 'speaker') for x in self.get_activity_as_speaker()]
if session:
activity = [x for x in activity if x[0].session == session]