Commit bf2d0b49 authored by Alain Takoudjou's avatar Alain Takoudjou

slapos_web: fix user ticked creation, update ticket method use proxy rule...

slapos_web: fix user ticked creation, update ticket method use proxy rule "Manager" to let user re-open closed tickets.
parent 85ebd535
from zExceptions import Unauthorized
portal = context.getPortalObject()
web_site = context.getWebSiteValue()
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()
# XXX Proxy role is Manager so user to open ticket which is closed.
# We check permissions
if not person:
raise Unauthorized("You need to be logged in before modify this object!")
if context.getDestinationDecision() != person.getRelativeUrl():
raise Unauthorized
request = context.REQUEST
if 'field_your_description' in request:
description = request['field_your_description']
......@@ -9,10 +18,14 @@ else:
return context.Base_redirect('view', keep_items={'portal_status_message':context.Base_translateString('No changes.')})
web_message_template = portal.restrictedTraverse(
portal.portal_preferences.getPreferredWebMessageTemplate())
portal.portal_preferences.getPreferredWebMessageTemplate())
web_message = web_message_template.Base_createCloneDocument(batch_mode=1)
# XXX init script is not called when cloning?
web_message.Event_init()
# web_message.Event_init()
# XXX cannot call init script here with proxy role as Manager.
web_message.setContentType(portal.portal_preferences.getPreferredTextFormat())
web_message.Event_generateReference()
web_message.edit(
title="Re: %s" % context.getTitle(),
content_type="text/plain",
......@@ -22,6 +35,7 @@ web_message.edit(
start_date=DateTime(),
follow_up_value=context,
)
web_message.stop(comment="Submitted from the web site contact form")
if portal.portal_workflow.isTransitionPossible(context, "validate"):
context.validate(comment="See %s" % web_message.getRelativeUrl())
......
......@@ -52,6 +52,14 @@
<key> <string>_params</string> </key>
<value> <string>*args, **kwargs</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Ticket_updateTicketWebMode</string> </value>
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title, description, resource</string> </value>
<value> <string>title, description, resource, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -299,7 +299,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>Ticket Type</string> </value>
<value> <string>python: "Ticket Type"</string> </value>
</item>
</dictionary>
</pickle>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment