concept listing improvements: show last author only, avoid duplicates
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@4139 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
b52c68edcb
commit
eddc98d19d
3 changed files with 37 additions and 11 deletions
|
@ -218,8 +218,6 @@ class BaseView(GenericView, I18NView):
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def modifiedRaw(self):
|
def modifiedRaw(self):
|
||||||
""" get date/time of last modification
|
|
||||||
"""
|
|
||||||
d = getattr(self.adapted, 'modified', None)
|
d = getattr(self.adapted, 'modified', None)
|
||||||
if not d:
|
if not d:
|
||||||
dc = IZopeDublinCore(self.context)
|
dc = IZopeDublinCore(self.context)
|
||||||
|
@ -234,7 +232,7 @@ class BaseView(GenericView, I18NView):
|
||||||
return d and d.strftime('%Y-%m-%d %H:%M') or ''
|
return d and d.strftime('%Y-%m-%d %H:%M') or ''
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def creators(self):
|
def creatorsRaw(self):
|
||||||
# TODO: use an IAuthorInfo (or similar) adapter
|
# TODO: use an IAuthorInfo (or similar) adapter
|
||||||
creators = getattr(self.adapted, 'authors', None) or []
|
creators = getattr(self.adapted, 'authors', None) or []
|
||||||
if not creators:
|
if not creators:
|
||||||
|
@ -246,7 +244,15 @@ class BaseView(GenericView, I18NView):
|
||||||
creators.append(principal.title)
|
creators.append(principal.title)
|
||||||
except PrincipalLookupError:
|
except PrincipalLookupError:
|
||||||
creators.append(c)
|
creators.append(c)
|
||||||
return ', '.join(creators)
|
return creators
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def creators(self):
|
||||||
|
return ', '.join(self.creatorsRaw)
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def lastCreator(self):
|
||||||
|
return self.creatorsRaw and self.creatorsRaw[-1] or u''
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def loopsRoot(self):
|
def loopsRoot(self):
|
||||||
|
|
|
@ -121,9 +121,15 @@ class BaseRelationView(BaseView):
|
||||||
self.other = relation.second
|
self.other = relation.second
|
||||||
self.context = getVersion(self.context, request)
|
self.context = getVersion(self.context, request)
|
||||||
self.predicate = relation.predicate
|
self.predicate = relation.predicate
|
||||||
|
self.predicates = [self.predicate] # allow for more than one relation
|
||||||
self.relation = relation
|
self.relation = relation
|
||||||
|
self.relations = [relation]
|
||||||
self.request = request
|
self.request = request
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def hash(self):
|
||||||
|
return '%s:%s' % (id(self.relation.first), id(self.relation.second))
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def adapted(self):
|
def adapted(self):
|
||||||
return adapted(self.context, self.languageInfo)
|
return adapted(self.context, self.languageInfo)
|
||||||
|
@ -172,7 +178,7 @@ class BaseRelationView(BaseView):
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def predicateTitle(self):
|
def predicateTitle(self):
|
||||||
return self.predicate.title
|
return ', ' .join(p.title for p in self.predicates)
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def predicateUrl(self):
|
def predicateUrl(self):
|
||||||
|
@ -263,7 +269,7 @@ class ConceptView(BaseView):
|
||||||
instance.view = self
|
instance.view = self
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
def getChildren(self, topLevelOnly=True, sort=True):
|
def getChildren(self, topLevelOnly=True, sort=True, noDuplicates=True):
|
||||||
cm = self.loopsRoot.getConceptManager()
|
cm = self.loopsRoot.getConceptManager()
|
||||||
hasType = cm.getTypePredicate()
|
hasType = cm.getTypePredicate()
|
||||||
params = self.params
|
params = self.params
|
||||||
|
@ -349,6 +355,17 @@ class ConceptView(BaseView):
|
||||||
from loops.browser.resource import ResourceRelationView
|
from loops.browser.resource import ResourceRelationView
|
||||||
yield ResourceRelationView(r, self.request, contextIsSecond=True)
|
yield ResourceRelationView(r, self.request, contextIsSecond=True)
|
||||||
|
|
||||||
|
def unique(self, rels):
|
||||||
|
result = Jeep()
|
||||||
|
for r in rels:
|
||||||
|
existing = result.get(r.hash)
|
||||||
|
if existing is not None:
|
||||||
|
existing.relations.append(r)
|
||||||
|
existing.predicates.append(r.predicate)
|
||||||
|
else:
|
||||||
|
result[r.hash] = r
|
||||||
|
return result.values()
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def view(self):
|
def view(self):
|
||||||
context = self.context
|
context = self.context
|
||||||
|
|
|
@ -91,7 +91,7 @@
|
||||||
<metal:children define-macro="conceptchildren">
|
<metal:children define-macro="conceptchildren">
|
||||||
<div tal:attributes="class string:content-$level;
|
<div tal:attributes="class string:content-$level;
|
||||||
ondblclick python: item.openEditWindow('configure.html')"
|
ondblclick python: item.openEditWindow('configure.html')"
|
||||||
tal:define="children python: list(item.children())"
|
tal:define="children python: list(item.unique(item.children()))"
|
||||||
tal:condition="children">
|
tal:condition="children">
|
||||||
<h2 i18n:translate=""
|
<h2 i18n:translate=""
|
||||||
tal:condition="show_headline|python:True">Children</h2>
|
tal:condition="show_headline|python:True">Children</h2>
|
||||||
|
@ -107,7 +107,8 @@
|
||||||
<tal:items repeat="related children">
|
<tal:items repeat="related children">
|
||||||
<tal:item define="class python: repeat['related'].odd() and 'even' or 'odd';
|
<tal:item define="class python: repeat['related'].odd() and 'even' or 'odd';
|
||||||
description related/description;
|
description related/description;
|
||||||
predicate related/predicate/title|string:;
|
xx_predicate related/predicate/title|string:;
|
||||||
|
predicate related/predicateTitle;
|
||||||
info python: ' | '.join(
|
info python: ' | '.join(
|
||||||
t for t in (description, predicate) if t)">
|
t for t in (description, predicate) if t)">
|
||||||
<tr tal:attributes="class class">
|
<tr tal:attributes="class class">
|
||||||
|
@ -120,8 +121,9 @@
|
||||||
</td>
|
</td>
|
||||||
<td class="center"><span tal:content="related/typeTitle"
|
<td class="center"><span tal:content="related/typeTitle"
|
||||||
i18n:translate="">Type</span></td>
|
i18n:translate="">Type</span></td>
|
||||||
<td><span tal:replace="related/modified">Type</span></td>
|
<td><span tal:replace="related/modified">2011-01-10</span></td>
|
||||||
<td><span tal:replace="related/creators">Type</span></td>
|
<td tal:attributes="title related/creators">
|
||||||
|
<span tal:replace="related/lastCreator">Author</span></td>
|
||||||
<td class="nowrap center"
|
<td class="nowrap center"
|
||||||
tal:define="target nocall:related;
|
tal:define="target nocall:related;
|
||||||
style nothing"
|
style nothing"
|
||||||
|
@ -198,7 +200,8 @@
|
||||||
<span tal:replace="related/context/sizeForDisplay">2 MB</span>
|
<span tal:replace="related/context/sizeForDisplay">2 MB</span>
|
||||||
</td>
|
</td>
|
||||||
<td><span tal:replace="related/modified">2007-03-30</span></td>
|
<td><span tal:replace="related/modified">2007-03-30</span></td>
|
||||||
<td><span tal:replace="related/creators">John</span></td>
|
<td tal:attributes="title related/creators">
|
||||||
|
<span tal:replace="related/lastCreator">Author</span></td>
|
||||||
<td class="nowrap center"
|
<td class="nowrap center"
|
||||||
tal:define="target nocall:related;
|
tal:define="target nocall:related;
|
||||||
style nothing"
|
style nothing"
|
||||||
|
|
Loading…
Add table
Reference in a new issue