provide new 'getViewForObject()' method for getting views in listings; use new view attribute 'listingTitle' in listings
This commit is contained in:
parent
62077c5dfb
commit
14b670166a
3 changed files with 41 additions and 14 deletions
|
@ -389,6 +389,40 @@ class BaseView(GenericView, I18NView):
|
|||
def uniqueId(self):
|
||||
return util.getUidForObject(self.context)
|
||||
|
||||
@Lazy
|
||||
def breadcrumbsTitle(self):
|
||||
return self.title
|
||||
|
||||
@Lazy
|
||||
def listingTitle(self):
|
||||
return self.title
|
||||
|
||||
def getViewForObject(self, obj):
|
||||
if obj is not None:
|
||||
obj = baseObject(obj)
|
||||
basicView = component.getMultiAdapter((obj, self.request))
|
||||
if hasattr(basicView, 'view'):
|
||||
return basicView.view
|
||||
|
||||
def viewIterator(self, objs):
|
||||
request = self.request
|
||||
for obj in objs:
|
||||
view = self.getViewForObject(obj)
|
||||
if view is None:
|
||||
view = BaseView(obj, request)
|
||||
yield view
|
||||
|
||||
def xx_viewIterator(self,obj):
|
||||
view = component.queryMultiAdapter(
|
||||
(o, request), name='index.html')
|
||||
#if view is None:
|
||||
# view = component.queryMultiAdapter((o, request), IBrowserView)
|
||||
if view is None:
|
||||
view = BaseView(o, request)
|
||||
if hasattr(view, 'view'): # use view setting for type
|
||||
view = view.view
|
||||
yield view
|
||||
|
||||
# type stuff
|
||||
|
||||
@Lazy
|
||||
|
@ -431,16 +465,6 @@ class BaseView(GenericView, I18NView):
|
|||
return absoluteURL(provider, self.request)
|
||||
return None
|
||||
|
||||
def viewIterator(self, objs):
|
||||
request = self.request
|
||||
for o in objs:
|
||||
view = component.queryMultiAdapter((o, request), name='index.html')
|
||||
#if view is None:
|
||||
# view = component.queryMultiAdapter((o, request), IBrowserView)
|
||||
if view is None:
|
||||
view = BaseView(o, request)
|
||||
yield view
|
||||
|
||||
def renderText(self, text, contentType):
|
||||
text = util.toUnicode(text)
|
||||
typeKey = util.renderingFactories.get(contentType, None)
|
||||
|
|
|
@ -122,7 +122,7 @@
|
|||
<img tal:define="icon row/icon"
|
||||
tal:condition="icon"
|
||||
tal:attributes="src icon/src" />
|
||||
<div tal:content="row/title" /></a>
|
||||
<div tal:content="row/listingTitle" /></a>
|
||||
</td>
|
||||
<td i18n:translate="" class="center"
|
||||
tal:content="row/longTypeTitle|row/typeTitle">Type</td>
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
"""
|
||||
Adapter and view class(es) for statistics reporting.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
from datetime import date, datetime
|
||||
|
@ -268,9 +266,14 @@ class TrackDetails(BaseView):
|
|||
obj = self.object
|
||||
node = self.view.nodeView
|
||||
url = node is not None and node.getUrlForTarget(obj) or ''
|
||||
view = self.view.getViewForObject(obj)
|
||||
if view is None:
|
||||
title = obj.title
|
||||
else:
|
||||
title = view.listingTitle
|
||||
versionable = IVersionable(self.object, None)
|
||||
version = versionable is not None and versionable.versionId or ''
|
||||
return dict(object=obj, title=obj.title,
|
||||
return dict(object=obj, title=title,
|
||||
type=self.longTypeTitle, url=url, version=version,
|
||||
canAccess=canAccessObject(obj))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue