Commit 436d8fb7 authored by Romain Courteaud's avatar Romain Courteaud

slapos_panel: allow uploading event's attachment

parent 2cefcd01
portal = context.getPortalObject()
REQUEST = context.REQUEST
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
# Max ~3Mb
if int(REQUEST.getHeader('Content-Length', 0)) > 3145728:
REQUEST.RESPONSE.setStatus(413)
return ""
if context.getPortalType() == 'Project':
project = context
else:
......@@ -12,6 +18,6 @@ support_request = project.Project_createSupportRequestWithCausality(
destination_decision=person.getRelativeUrl()
)
support_request.Ticket_addSlapOSEvent(title, description, resource=resource, batch=True)
support_request.Ticket_addSlapOSEvent(title, description, attachment=attachment, resource=resource, batch=True)
return support_request.Base_redirect()
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title, description, resource, **kw</string> </value>
<value> <string>title, description, resource, attachment=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -91,6 +91,7 @@
<list>
<string>your_title</string>
<string>your_description</string>
<string>your_attachment</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_attachment</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_file_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Attachment</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from Products.ERP5Type.Errors import UnsupportedWorkflowMethod
REQUEST = context.REQUEST
portal = context.getPortalObject()
ticket = context
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
person_relative_url = person.getRelativeUrl()
# Max ~3Mb
if int(REQUEST.getHeader('Content-Length', 0)) > 3145728:
REQUEST.RESPONSE.setStatus(413)
return ""
if person_relative_url == ticket.getDestination():
direction = 'incoming'
else:
......@@ -18,6 +24,7 @@ event = ticket.Ticket_createProjectEvent(
resource,
text_content=text_content,
content_type='text/plain',
attachment=attachment,
source=person_relative_url
)
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title, text_content, batch=None, resource=None, **kw</string> </value>
<value> <string>title, text_content, attachment=None, batch=None, resource=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -91,6 +91,7 @@
<list>
<string>your_title</string>
<string>your_text_content</string>
<string>your_attachment</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_attachment</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_file_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Attachment</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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