Add custom permission for managing contests
This commit is contained in:
parent
0dbfd8973c
commit
9778559dd2
|
@ -1,4 +1,2 @@
|
|||
# -*- extra stuff goes here -*-
|
||||
|
||||
def initialize(context):
|
||||
"""Initializer called when used as a Zope 2 product."""
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
<!-- Include configuration for dependencies listed in setup.py -->
|
||||
<includeDependencies package="." />
|
||||
|
||||
<permission
|
||||
id="tabellio.contest.Manage"
|
||||
title="Contests: Manage Contests"
|
||||
/>
|
||||
|
||||
<!-- Grok the package to initialise schema interfaces and content classes -->
|
||||
<grok:grok package="." />
|
||||
|
||||
|
@ -22,15 +27,15 @@
|
|||
name="remove"
|
||||
for="tabellio.contest.participant.IParticipant"
|
||||
class=".participant.Remove"
|
||||
permission="zope2.View"
|
||||
/> <!-- XXX: permissions -->
|
||||
permission="tabellio.contest.Manage"
|
||||
/>
|
||||
|
||||
<browser:view
|
||||
name="pick"
|
||||
for="tabellio.contest.contest.IContest"
|
||||
class=".contest.PickWinner"
|
||||
permission="zope2.View"
|
||||
/> <!-- XXX: permissions -->
|
||||
permission="tabellio.contest.Manage"
|
||||
/>
|
||||
|
||||
<!-- Register an extension profile to make the product installable -->
|
||||
<genericsetup:registerProfile
|
||||
|
|
|
@ -48,7 +48,7 @@ class Thanks(grok.View):
|
|||
|
||||
class Participants(grok.View):
|
||||
grok.context(IContest)
|
||||
grok.require('zope2.View') # XXX
|
||||
grok.require('tabellio.contest.Manage')
|
||||
|
||||
def has_winners(self):
|
||||
for object in self.context.objectValues():
|
||||
|
@ -67,6 +67,7 @@ class Participants(grok.View):
|
|||
class Participate(BrowserView):
|
||||
def __call__(self):
|
||||
plone_tool = getToolByName(self.context, 'plone_utils')
|
||||
portal_types = getToolByName(self.context, "portal_types")
|
||||
|
||||
new_id = plone_tool.normalizeString(self.request.form.get('name'))
|
||||
if new_id in self.context:
|
||||
|
@ -77,11 +78,13 @@ class Participate(BrowserView):
|
|||
continue
|
||||
new_id = '%s-%s' % (new_id, counter)
|
||||
break
|
||||
self.context.invokeFactory('tabellio.contest.participant', new_id)
|
||||
|
||||
type_info = portal_types.getTypeInfo('tabellio.contest.participant')
|
||||
type_info._constructInstance(self.context, new_id)
|
||||
object = self.context[new_id]
|
||||
for attr in ('name', 'address', 'zipcode', 'locality', 'phone',
|
||||
'email', 'answer1', 'answer2'):
|
||||
setattr(object, attr, self.request.form.get(attr))
|
||||
setattr(object, attr, self.request.form.get(attr, '').strip())
|
||||
|
||||
object.datetime = datetime.datetime.now()
|
||||
object.ipaddress = self.request._client_addr
|
||||
|
|
|
@ -41,11 +41,11 @@
|
|||
<!-- Actions -->
|
||||
<action title="View" action_id="view" category="object" condition_expr=""
|
||||
url_expr="string:${object_url}" visible="True">
|
||||
<permission value="View"/>
|
||||
<permission value="tabellio.contest.Manage"/>
|
||||
</action>
|
||||
<action title="Edit" action_id="edit" category="object" condition_expr=""
|
||||
url_expr="string:${object_url}/edit" visible="True">
|
||||
<permission value="Modify portal content"/>
|
||||
<permission value="tabellio.contest.Manage"/>
|
||||
</action>
|
||||
</object>
|
||||
|
||||
|
|
Reference in New Issue