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
|
||||
def modifiedRaw(self):
|
||||
""" get date/time of last modification
|
||||
"""
|
||||
d = getattr(self.adapted, 'modified', None)
|
||||
if not d:
|
||||
dc = IZopeDublinCore(self.context)
|
||||
|
@ -234,7 +232,7 @@ class BaseView(GenericView, I18NView):
|
|||
return d and d.strftime('%Y-%m-%d %H:%M') or ''
|
||||
|
||||
@Lazy
|
||||
def creators(self):
|
||||
def creatorsRaw(self):
|
||||
# TODO: use an IAuthorInfo (or similar) adapter
|
||||
creators = getattr(self.adapted, 'authors', None) or []
|
||||
if not creators:
|
||||
|
@ -246,7 +244,15 @@ class BaseView(GenericView, I18NView):
|
|||
creators.append(principal.title)
|
||||
except PrincipalLookupError:
|
||||
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
|
||||
def loopsRoot(self):
|
||||
|
|
|
@ -121,9 +121,15 @@ class BaseRelationView(BaseView):
|
|||
self.other = relation.second
|
||||
self.context = getVersion(self.context, request)
|
||||
self.predicate = relation.predicate
|
||||
self.predicates = [self.predicate] # allow for more than one relation
|
||||
self.relation = relation
|
||||
self.relations = [relation]
|
||||
self.request = request
|
||||
|
||||
@Lazy
|
||||
def hash(self):
|
||||
return '%s:%s' % (id(self.relation.first), id(self.relation.second))
|
||||
|
||||
@Lazy
|
||||
def adapted(self):
|
||||
return adapted(self.context, self.languageInfo)
|
||||
|
@ -172,7 +178,7 @@ class BaseRelationView(BaseView):
|
|||
|
||||
@Lazy
|
||||
def predicateTitle(self):
|
||||
return self.predicate.title
|
||||
return ', ' .join(p.title for p in self.predicates)
|
||||
|
||||
@Lazy
|
||||
def predicateUrl(self):
|
||||
|
@ -263,7 +269,7 @@ class ConceptView(BaseView):
|
|||
instance.view = self
|
||||
return instance
|
||||
|
||||
def getChildren(self, topLevelOnly=True, sort=True):
|
||||
def getChildren(self, topLevelOnly=True, sort=True, noDuplicates=True):
|
||||
cm = self.loopsRoot.getConceptManager()
|
||||
hasType = cm.getTypePredicate()
|
||||
params = self.params
|
||||
|
@ -349,6 +355,17 @@ class ConceptView(BaseView):
|
|||
from loops.browser.resource import ResourceRelationView
|
||||
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
|
||||
def view(self):
|
||||
context = self.context
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
<metal:children define-macro="conceptchildren">
|
||||
<div tal:attributes="class string:content-$level;
|
||||
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">
|
||||
<h2 i18n:translate=""
|
||||
tal:condition="show_headline|python:True">Children</h2>
|
||||
|
@ -107,7 +107,8 @@
|
|||
<tal:items repeat="related children">
|
||||
<tal:item define="class python: repeat['related'].odd() and 'even' or 'odd';
|
||||
description related/description;
|
||||
predicate related/predicate/title|string:;
|
||||
xx_predicate related/predicate/title|string:;
|
||||
predicate related/predicateTitle;
|
||||
info python: ' | '.join(
|
||||
t for t in (description, predicate) if t)">
|
||||
<tr tal:attributes="class class">
|
||||
|
@ -120,8 +121,9 @@
|
|||
</td>
|
||||
<td class="center"><span tal:content="related/typeTitle"
|
||||
i18n:translate="">Type</span></td>
|
||||
<td><span tal:replace="related/modified">Type</span></td>
|
||||
<td><span tal:replace="related/creators">Type</span></td>
|
||||
<td><span tal:replace="related/modified">2011-01-10</span></td>
|
||||
<td tal:attributes="title related/creators">
|
||||
<span tal:replace="related/lastCreator">Author</span></td>
|
||||
<td class="nowrap center"
|
||||
tal:define="target nocall:related;
|
||||
style nothing"
|
||||
|
@ -198,7 +200,8 @@
|
|||
<span tal:replace="related/context/sizeForDisplay">2 MB</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"
|
||||
tal:define="target nocall:related;
|
||||
style nothing"
|
||||
|
|
Loading…
Add table
Reference in a new issue