some adjustments on permissions for editing and showing certain portlets
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1621 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
ee5586ce3f
commit
8a6a9a938d
6 changed files with 22 additions and 11 deletions
|
@ -239,18 +239,19 @@ class BaseView(GenericView):
|
||||||
|
|
||||||
def openEditWindow(self, viewName='edit.html'):
|
def openEditWindow(self, viewName='edit.html'):
|
||||||
if self.editable:
|
if self.editable:
|
||||||
return "openEditWindow('%s/@@%s')" % (self.url, viewName)
|
#if self.request.principal.id == 'rootadmin'
|
||||||
|
return "openEditWindow('%s/@@%s')" % (self.url, viewName)
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def xeditable(self):
|
def xeditable(self):
|
||||||
return self.request.principal.id == 'rootadmin'
|
ct = getattr(self.context, 'contentType', '')
|
||||||
#return getattr(self.context, 'contentType', '').startswith('text/')
|
if ct.startswith('text/'):
|
||||||
|
return self.request.principal.id == 'rootadmin'
|
||||||
|
return canWrite(self.context, 'title')
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def inlineEditingActive(self):
|
def inlineEditingActive(self):
|
||||||
#return False
|
|
||||||
#return self.request.principal.id == 'rootadmin'
|
|
||||||
# this may depend on system and user settings...
|
# this may depend on system and user settings...
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ from zope.app.container.contained import ObjectRemovedEvent
|
||||||
from zope.app.form.browser.interfaces import ITerms
|
from zope.app.form.browser.interfaces import ITerms
|
||||||
from zope.app.form.interfaces import IDisplayWidget
|
from zope.app.form.interfaces import IDisplayWidget
|
||||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||||
|
from zope.app.security.interfaces import IUnauthenticatedPrincipal
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
from zope.dottedname.resolve import resolve
|
from zope.dottedname.resolve import resolve
|
||||||
from zope.event import notify
|
from zope.event import notify
|
||||||
|
@ -80,7 +81,8 @@ class ConceptView(BaseView):
|
||||||
def __init__(self, context, request):
|
def __init__(self, context, request):
|
||||||
super(ConceptView, self).__init__(context, request)
|
super(ConceptView, self).__init__(context, request)
|
||||||
cont = self.controller
|
cont = self.controller
|
||||||
if cont is not None:
|
if (cont is not None and not IUnauthenticatedPrincipal.providedBy(
|
||||||
|
self.request.principal)):
|
||||||
cont.macros.register('portlet_right', 'parents', title='Parents',
|
cont.macros.register('portlet_right', 'parents', title='Parents',
|
||||||
subMacro=self.template.macros['parents'],
|
subMacro=self.template.macros['parents'],
|
||||||
position=0, info=self)
|
position=0, info=self)
|
||||||
|
|
|
@ -76,7 +76,8 @@ class NodeView(BaseView):
|
||||||
cm.register('js', 'loops.js', resourceName='loops.js')
|
cm.register('js', 'loops.js', resourceName='loops.js')
|
||||||
cm.register('portlet_left', 'navigation', title='Navigation',
|
cm.register('portlet_left', 'navigation', title='Navigation',
|
||||||
subMacro=self.template.macros['menu'])
|
subMacro=self.template.macros['menu'])
|
||||||
if not IUnauthenticatedPrincipal.providedBy(self.request.principal):
|
#if not IUnauthenticatedPrincipal.providedBy(self.request.principal):
|
||||||
|
if canWrite(self.context, 'title'):
|
||||||
#cm.register('portlet_right', 'clipboard', title='Clipboard',
|
#cm.register('portlet_right', 'clipboard', title='Clipboard',
|
||||||
# subMacro=self.template.macros['clipboard'])
|
# subMacro=self.template.macros['clipboard'])
|
||||||
# this belongs to loops.organize; how to register portlets
|
# this belongs to loops.organize; how to register portlets
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
style="float: right; border: 1px solid #ccc;
|
style="float: right; border: 1px solid #ccc;
|
||||||
margin-top: 1em">
|
margin-top: 1em">
|
||||||
<span id="xedit_icon"
|
<span id="xedit_icon"
|
||||||
tal:condition="item/xeditable | nothing">
|
tal:condition="target/xeditable | nothing">
|
||||||
<a href="#" title="Edit" style="padding: 5px"
|
<a href="#" title="Edit" style="padding: 5px"
|
||||||
tal:attributes="href string:${item/realTargetUrl}/external_edit;
|
tal:attributes="href string:${item/realTargetUrl}/external_edit;
|
||||||
title string:Edit '${target/title}' with External Editor"><img
|
title string:Edit '${target/title}' with External Editor"><img
|
||||||
|
|
|
@ -32,10 +32,10 @@
|
||||||
|
|
||||||
<metal:block define-macro="image">
|
<metal:block define-macro="image">
|
||||||
<div tal:attributes="ondblclick python: item.openEditWindow('edit.html')">
|
<div tal:attributes="ondblclick python: item.openEditWindow('edit.html')">
|
||||||
<h3 tal:content="item/title">Title</h3>
|
<h3 tal:content="item/title">Title</h3><br />
|
||||||
<p><i tal:content="item/description">Description</i></p>
|
|
||||||
<img src="#"
|
<img src="#"
|
||||||
tal:attributes="src string:${view/url}/.target${view/targetId}/view" />
|
tal:attributes="src string:${view/url}/.target${view/targetId}/view" />
|
||||||
|
<p><i tal:content="item/description">Description</i></p>
|
||||||
</div>
|
</div>
|
||||||
</metal:block>
|
</metal:block>
|
||||||
|
|
||||||
|
|
|
@ -386,7 +386,14 @@ Now we are ready to set up a view on our page node:
|
||||||
|
|
||||||
The elements responsible for presentation are controlled by a controller
|
The elements responsible for presentation are controlled by a controller
|
||||||
object; note that we have to provide a named template 'loops.node_macros' that
|
object; note that we have to provide a named template 'loops.node_macros' that
|
||||||
is used to retrieve a macro used by NodeView:
|
is used to retrieve a macro used by NodeView.
|
||||||
|
|
||||||
|
As the display of the standard macros is controlled by permissions we have
|
||||||
|
to install a checker first.
|
||||||
|
|
||||||
|
>>> from zope.security.checker import NamesChecker, defineChecker
|
||||||
|
>>> nodeChecker = NamesChecker(('body', 'title',))
|
||||||
|
>>> defineChecker(Node, nodeChecker)
|
||||||
|
|
||||||
>>> from cybertools.browser.controller import Controller
|
>>> from cybertools.browser.controller import Controller
|
||||||
>>> from loops.browser.util import node_macros
|
>>> from loops.browser.util import node_macros
|
||||||
|
|
Loading…
Add table
Reference in a new issue