From 3d50688e115cc35e17872a9a17f25b856f6379d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sun, 4 Dec 2011 16:36:22 +0100 Subject: [PATCH] add display of related documents --- tabellio/pfbviews/document.pt | 19 +++++++++++++++++++ tabellio/pfbviews/document.py | 7 +++++-- tabellio/pfbviews/question.pt | 16 +++++++++++++++- tabellio/pfbviews/question.py | 7 +++++-- 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/tabellio/pfbviews/document.pt b/tabellio/pfbviews/document.pt index d359316..b962f6a 100644 --- a/tabellio/pfbviews/document.pt +++ b/tabellio/pfbviews/document.pt @@ -68,6 +68,25 @@ +
+ +
+ +
+ +
+ +
+
+
diff --git a/tabellio/pfbviews/document.py b/tabellio/pfbviews/document.py index d94f000..7d93488 100644 --- a/tabellio/pfbviews/document.py +++ b/tabellio/pfbviews/document.py @@ -1,8 +1,11 @@ from Products.Five import BrowserView class View(BrowserView): - pass - + def related_docs(self): + if not self.context.related_docs: + return [] + objects = [x.to_object for x in self.context.related_docs] + return sorted(objects, lambda x,y: cmp(x.reftitle, y.reftitle)) class DocumentDownload(BrowserView): def __call__(self): diff --git a/tabellio/pfbviews/question.pt b/tabellio/pfbviews/question.pt index 808028a..f264d9c 100644 --- a/tabellio/pfbviews/question.pt +++ b/tabellio/pfbviews/question.pt @@ -57,7 +57,21 @@
- +
+ +
+ +
+ +
diff --git a/tabellio/pfbviews/question.py b/tabellio/pfbviews/question.py index 6a398fd..1e72521 100644 --- a/tabellio/pfbviews/question.py +++ b/tabellio/pfbviews/question.py @@ -1,5 +1,8 @@ from Products.Five import BrowserView class View(BrowserView): - pass - + def related_docs(self): + if not self.context.related_docs: + return [] + objects = [x.to_object for x in self.context.related_docs] + return sorted(objects, lambda x,y: cmp(x.reftitle, y.reftitle))