summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerghei MIHAI <smihai@entrouvert.com>2013-11-13 10:43:45 (GMT)
committerSerghei MIHAI <smihai@entrouvert.com>2013-11-13 10:43:45 (GMT)
commitf0199bab47dde6c1e47838866d8a52f2f64bb897 (patch)
tree9b8001cde55ee76e2937aced683ce8ecee6f88c3
parent3974dee99f116d6fe5336e17241a48a8474c8c91 (diff)
downloadtabellio.webviews-f0199bab47dde6c1e47838866d8a52f2f64bb897.zip
tabellio.webviews-f0199bab47dde6c1e47838866d8a52f2f64bb897.tar.gz
tabellio.webviews-f0199bab47dde6c1e47838866d8a52f2f64bb897.tar.bz2
documents dont le deputé est orateur ou reporteur affichés
-rw-r--r--tabellio/webviews/deputy.pt2
-rw-r--r--tabellio/webviews/deputy.py47
2 files changed, 48 insertions, 1 deletions
diff --git a/tabellio/webviews/deputy.pt b/tabellio/webviews/deputy.pt
index ea28ec8..2dc4164 100644
--- a/tabellio/webviews/deputy.pt
+++ b/tabellio/webviews/deputy.pt
@@ -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>
diff --git a/tabellio/webviews/deputy.py b/tabellio/webviews/deputy.py
index 36e4fec..3dc21f7 100644
--- a/tabellio/webviews/deputy.py
+++ b/tabellio/webviews/deputy.py
@@ -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]