From 5d3bcf3cfae965ebaaf7f719373dec46285bfe36 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Mon, 5 Mar 2012 18:36:27 +0100 Subject: [PATCH 1/2] provide more control on what is shown in list or grid via new 'represents' predicate for resources --- browser/lobo/standard.pt | 4 ++-- browser/lobo/standard.py | 28 ++++++++++++++++++++++++---- organize/stateful/base.py | 10 +++++++--- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/browser/lobo/standard.pt b/browser/lobo/standard.pt index bb655dc..40a8061 100644 --- a/browser/lobo/standard.pt +++ b/browser/lobo/standard.pt @@ -17,7 +17,7 @@ title cell/description">

- +
@@ -36,7 +36,7 @@
- +
diff --git a/browser/lobo/standard.py b/browser/lobo/standard.py index b70d4eb..5b80e36 100644 --- a/browser/lobo/standard.py +++ b/browser/lobo/standard.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2011 Helmut Merz helmutm@cy55.de +# Copyright (c) 2012 Helmut Merz helmutm@cy55.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,8 +18,6 @@ """ View classes for lobo (blueprint-based) layouts. - -$Id$ """ from cgi import parse_qs @@ -66,8 +64,20 @@ class ConceptView(BaseConceptView): @Lazy def resources(self): + return self.getResources() + + @Lazy + def representingResources(self): + pred = self.representationPredicate + if pred is None: + return {} + return self.getResources([pred]) + + def getResources(self, predicates=None): result = dict(texts=[], images=[], files=[]) - for r in self.context.getResources([self.defaultPredicate]): + if predicates is None: + predicates = [self.defaultPredicate] + for r in self.context.getResources(predicates): if r.contentType.startswith('text/'): result['texts'].append(r) if r.contentType.startswith('image/'): @@ -81,6 +91,10 @@ class ConceptView(BaseConceptView): for r in self.resources['images']: yield r + @Lazy + def representationPredicate(self): + return self.conceptManager.get('represents') + # properties from base class: title, description, renderedDescription @Lazy @@ -99,6 +113,12 @@ class ConceptView(BaseConceptView): return u'' return self.renderDescription(self.textDescription) + @Lazy + def textRepresentation(self): + for r in self.representingResources.get('texts', []): + return self.renderText(r.data, r.contentType) + return self.renderedDescription + @Lazy def targetUrl(self): return self.nodeView.getUrlForTarget(self.context) diff --git a/organize/stateful/base.py b/organize/stateful/base.py index f6da53b..fc2d942 100644 --- a/organize/stateful/base.py +++ b/organize/stateful/base.py @@ -67,9 +67,13 @@ class StatefulConceptIndexInfo(IndexInfo): @property def availableStatesDefinitions(self): globalOptions = IOptions(self.context.getLoopsRoot()) - typeOptions = IOptions(adapted(self.context.conceptType)) - return (globalOptions('organize.stateful.concept', []) + - typeOptions('organize.stateful', [])) + type = self.context.conceptType + if type is None: # may happen during object creation + return globalOptions('organize.stateful.concept', []) + else: + typeOptions = IOptions(adapted(type)) + return (globalOptions('organize.stateful.concept', []) + + typeOptions('organize.stateful', [])) class StatefulResourceIndexInfo(IndexInfo): From 66e1a718515c9e4e3d23d72cdfa86918d0be03c0 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Mon, 5 Mar 2012 19:41:54 +0100 Subject: [PATCH 2/2] standard listing: show predicate also for resources --- browser/concept_macros.pt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/browser/concept_macros.pt b/browser/concept_macros.pt index 5123243..8f11c00 100644 --- a/browser/concept_macros.pt +++ b/browser/concept_macros.pt @@ -210,7 +210,10 @@ item.editable and 'dojo.dnd.Source' or ''"> + description related/description; + predicate related/predicateTitle; + info python: ' | '.join( + t for t in (description, predicate) if t)"> + title info">
Resource Title