Commit bd01371a authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Fixup add related event

   Change to use the proper API from ticket_slap_interface_workflow.
parent 0bfe0d03
......@@ -5,12 +5,8 @@
data-i18n=Title
data-i18n=Include your message
data-i18n=Your Message
data-i18n=Source
data-i18n=Follow up
data-i18n=Portal Type
data-i18n=Web Message
data-i18n=Parent Relative Url
data-i18n=New Message
data-i18n=New Message created.
-->
<head>
......
......@@ -283,7 +283,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>982.16656.9604.44475</string> </value>
<value> <string>1001.17455.63633.53794</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -301,7 +301,7 @@
</tuple>
<state>
<tuple>
<float>1583924073.29</float>
<float>1656611535.78</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -16,6 +16,8 @@
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", "notifySubmitted")
/////////////////////////////////////////////////////////////////
// declared methods
......@@ -26,17 +28,35 @@
.onEvent('submit', function () {
var gadget = this;
return gadget.getDeclaredGadget('form_view')
return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
return form_gadget.getContent();
return RSVP.all([form_gadget.getContent(),
gadget.getSetting('hateoas_url')]);
})
.push(function (doc) {
return gadget.jio_post(doc);
.push(function (result) {
var doc = result[0],
url = result[1];
return gadget.jio_putAttachment(gadget.state.jio_key,
url + gadget.state.jio_key + "/Ticket_requestEvent",
{title: doc.title,
text_content: doc.text_content});
})
/*.push(function (attachment) {
return jIO.util.readBlobAsText(attachment.target.response);
})
.push(function (response) {
return JSON.parse(response.target.result);
})*/
.push(function () {
return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'})
.push(function () {
// Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change",
"options": {"jio_key": gadget.state.jio_key,
"page": "slap_controller"}});
"options": {"jio_key": gadget.state.jio_key, "page": "slap_controller"}});
});
});
})
......@@ -52,12 +72,8 @@
"Title",
"Include your message",
"Your Message",
"Source",
"Follow up",
"Portal Type",
"Web Message",
"Parent Relative Url",
"New Message"
"New Message",
"New Message created."
];
gadget.state.jio_key = options.jio_key;
......@@ -71,7 +87,8 @@
]);
})
.push(function (result) {
page_title_translation = result[3][9];
page_title_translation = result[3][4];
gadget.message_translation = result[3][5];
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
......@@ -96,50 +113,6 @@
"key": "text_content",
"hidden": 0,
"type": "TextAreaField"
},
"my_source": {
"description": "",
"title": result[3][4],
"default": result[1],
"css_class": "",
"required": 1,
"editable": 1,
"key": "source",
"hidden": 1,
"type": "StringField"
},
"my_follow_up": {
"description": "",
"title": result[3][5],
"default": gadget.state.jio_key,
"css_class": "",
"required": 1,
"editable": 1,
"key": "follow_up",
"hidden": 1,
"type": "StringField"
},
"my_portal_type": {
"description": result[3][0],
"title": result[3][6],
"default": "Web Message",
"css_class": "",
"required": 1,
"editable": 1,
"key": "portal_type",
"hidden": 1,
"type": "StringField"
},
"my_parent_relative_url": {
"description": "",
"title": result[3][8],
"default": "event_module",
"css_class": "",
"required": 1,
"editable": 1,
"key": "parent_relative_url",
"hidden": 1,
"type": "StringField"
}
}},
"_links": {
......@@ -152,18 +125,11 @@
form_definition: {
group_list: [[
"center",
[["my_title"], ["my_text_content"], ["my_follow_up"],
["my_portal_type"], ["my_parent_relative_url"],
["my_follow_up"], ["my_source"]]
[["my_title"], ["my_text_content"]]
]]
}
});
})
.push(function () {
return gadget.updatePanel({
jio_key: "support_request_module"
});
})
.push(function () {
return RSVP.all([
gadget.getUrlFor({command: 'history_previous'})
......
......@@ -290,7 +290,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>987.11837.51741.39355</string> </value>
<value> <string>1001.17558.20370.27699</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -308,7 +308,7 @@
</tuple>
<state>
<tuple>
<float>1602260993.65</float>
<float>1656617846.12</float>
<string>UTC</string>
</tuple>
</state>
......
import json
portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
request = context.REQUEST
response = request.RESPONSE
if person is None:
response.setStatus(403)
else:
request_kw = {
"event_title" : title,
"event_content": text_content,
"event_source": person.getRelativeUrl()
}
context.requestEvent(**request_kw)
event_relative_url = request.get('event_relative_url')
response.setHeader('Content-Type', "application/json")
return json.dumps({
"relative_url": event_relative_url
})
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title, text_content</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Ticket_requestEvent</string> </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