Add some navigation buttons
This commit is contained in:
parent
3fb941ee43
commit
691239023c
|
@ -30,6 +30,13 @@
|
|||
permission="tabellio.contest.Manage"
|
||||
/>
|
||||
|
||||
<browser:view
|
||||
name="manage"
|
||||
for="tabellio.contest.contest.IContest"
|
||||
class=".contest.Manage"
|
||||
permission="tabellio.contest.Manage"
|
||||
/>
|
||||
|
||||
<browser:view
|
||||
name="pick"
|
||||
for="tabellio.contest.contest.IContest"
|
||||
|
|
|
@ -3,6 +3,8 @@ import random
|
|||
|
||||
from five import grok
|
||||
from zope import schema
|
||||
from Acquisition import aq_inner
|
||||
from AccessControl import getSecurityManager
|
||||
from Products.Five.browser import BrowserView
|
||||
from Products.CMFCore.utils import getToolByName
|
||||
|
||||
|
@ -40,6 +42,10 @@ class View(grok.View):
|
|||
def question2answerslist(self):
|
||||
return self.context.question2answers.split('\n')
|
||||
|
||||
def can_manage(self):
|
||||
return getSecurityManager().checkPermission('tabellio.contest.Manage',
|
||||
aq_inner(self.context))
|
||||
|
||||
|
||||
class Thanks(grok.View):
|
||||
grok.context(IContest)
|
||||
|
@ -102,3 +108,17 @@ class PickWinner(BrowserView):
|
|||
self.request.response.redirect('./participants')
|
||||
|
||||
|
||||
class Manage(BrowserView):
|
||||
def __call__(self):
|
||||
if self.request.form.get('participants'):
|
||||
self.request.response.redirect('./participants')
|
||||
elif self.request.form.get('close'):
|
||||
self.context.active = False
|
||||
self.request.response.redirect('./')
|
||||
elif self.request.form.get('open'):
|
||||
self.context.active = True
|
||||
self.request.response.redirect('./')
|
||||
elif self.request.form.get('back'):
|
||||
self.request.response.redirect('./')
|
||||
|
||||
|
||||
|
|
|
@ -17,6 +17,13 @@
|
|||
|
||||
<div tal:replace="structure provider:plone.belowcontenttitle" />
|
||||
|
||||
<p>
|
||||
<form action="@@manage">
|
||||
<input type="submit" name="back"
|
||||
value="Retourner sur la page du concours"/>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<div tal:replace="structure provider:plone.abovecontentbody" />
|
||||
|
||||
<p tal:condition="view/has_winners">
|
||||
|
|
|
@ -17,6 +17,17 @@
|
|||
|
||||
<div tal:replace="structure provider:plone.belowcontenttitle" />
|
||||
|
||||
<div tal:condition="context/active">
|
||||
|
||||
<p tal:condition="view/can_manage">
|
||||
<form action="@@manage">
|
||||
<input type="submit" name="close" value="Fermer le concours"/>
|
||||
<input type="submit" name="participants"
|
||||
value="Voir la liste des participants"/>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
|
||||
<p tal:content="context/intro">
|
||||
Lorem ipsum.
|
||||
</p>
|
||||
|
@ -50,10 +61,22 @@
|
|||
<input type="submit" name="submit" value="Envoyer"/>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<div tal:condition="not:context/active">
|
||||
Ce concours est fermé.
|
||||
<p tal:condition="view/can_manage">
|
||||
<form action="@@manage">
|
||||
<input type="submit" name="open" value="Ouvrir le concours"/>
|
||||
<input type="submit" name="participants"
|
||||
tal:condition="context/objectValues" value="Voir la liste des participants"/>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Ce concours est fermé.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div tal:replace="structure provider:plone.belowcontentbody" />
|
||||
|
|
Reference in New Issue