show object actions only for logged-in users

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2596 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2008-05-15 13:39:16 +00:00
parent c98f77ac46
commit 8b5df16afc
3 changed files with 13 additions and 4 deletions

View file

@ -28,6 +28,7 @@ from zope.app.form.browser.interfaces import ITerms
from zope.app.i18n.interfaces import ITranslationDomain from zope.app.i18n.interfaces import ITranslationDomain
from zope.app.security.interfaces import IAuthentication from zope.app.security.interfaces import IAuthentication
from zope.app.pagetemplate import ViewPageTemplateFile from zope.app.pagetemplate import ViewPageTemplateFile
from zope.app.security.interfaces import IUnauthenticatedPrincipal
from zope.app.security.interfaces import PrincipalLookupError from zope.app.security.interfaces import PrincipalLookupError
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from zope.dottedname.resolve import resolve from zope.dottedname.resolve import resolve
@ -400,7 +401,7 @@ class BaseView(GenericView, I18NView):
result.append(stf) result.append(stf)
return result return result
# controlling editing # controlling actions and editing
@Lazy @Lazy
def editable(self): def editable(self):
@ -415,6 +416,10 @@ class BaseView(GenericView, I18NView):
actions.extend(self.actions[category](self, page=page, target=target)) actions.extend(self.actions[category](self, page=page, target=target))
return actions return actions
@Lazy
def showObjectActions(self):
return not IUnauthenticatedPrincipal.providedBy(self.request.principal)
def openEditWindow(self, viewName='edit.html'): def openEditWindow(self, viewName='edit.html'):
if self.editable: if self.editable:
if checkPermission('loops.ManageSite', self.context): if checkPermission('loops.ManageSite', self.context):

View file

@ -114,7 +114,8 @@
<th i18n:translate="">Size</th> <th i18n:translate="">Size</th>
<th i18n:translate="">Modification Date</th> <th i18n:translate="">Modification Date</th>
<th i18n:translate="">Author(s)</th> <th i18n:translate="">Author(s)</th>
<th i18n:translate="">Info</th> <th i18n:translate=""
tal:condition="view/showObjectActions">Info</th>
</tr> </tr>
<tal:items repeat="related resources"> <tal:items repeat="related resources">
<tal:item define="class python: repeat['related'].odd() and 'even' or 'odd'; <tal:item define="class python: repeat['related'].odd() and 'even' or 'odd';
@ -144,7 +145,8 @@
<td><span tal:replace="related/creators">John</span></td> <td><span tal:replace="related/creators">John</span></td>
<td style="white-space: nowrap" <td style="white-space: nowrap"
tal:define="target nocall:related; tal:define="target nocall:related;
style nothing"> style nothing"
tal:condition="view/showObjectActions">
<div metal:use-macro="views/node_macros/object_actions" /> <div metal:use-macro="views/node_macros/object_actions" />
</td> </td>
</tr> </tr>

View file

@ -2,7 +2,9 @@
<div tal:attributes="ondblclick python: item.openEditWindow('configure.html')"> <div tal:attributes="ondblclick python: item.openEditWindow('configure.html')">
<tal:body define="itemNum view/itemNum; <tal:body define="itemNum view/itemNum;
id string:$itemNum.body;"> id string:$itemNum.body;">
<div metal:use-macro="views/node_macros/object_actions" /> <tal:actions condition="view/showObjectActions">
<div metal:use-macro="views/node_macros/object_actions" />
</tal:actions>
<h1 tal:content="item/title">Title</h1> <h1 tal:content="item/title">Title</h1>
<p tal:define="description description|item/description" <p tal:define="description description|item/description"
tal:condition="description"> tal:condition="description">