Commit 560c946f authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Fixup Support Request Close

   Events are creates via script (and API) now, instead jio_post.
parent 691c77ac
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment") .declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("jio_get", "jio_get") .declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("getTranslationList", "getTranslationList") .declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", "notifySubmitted")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
...@@ -26,24 +28,28 @@ ...@@ -26,24 +28,28 @@
.onEvent('submit', function () { .onEvent('submit', function () {
var gadget = this; var gadget = this;
return gadget.getDeclaredGadget('form_view') return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) { .push(function (form_gadget) {
return form_gadget.getContent(); return RSVP.all([form_gadget.getContent(),
gadget.getSetting('hateoas_url')]);
}) })
.push(function (doc) { .push(function (result) {
return gadget.jio_post(doc) var doc = result[0],
.push(function () { url = result[1];
return gadget.getSetting("hateoas_url"); return gadget.jio_putAttachment(gadget.state.jio_key,
}) url + gadget.state.jio_key + "/SupportRequest_close",
.push(function (url) { {text_content: doc.text_content});
return gadget.jio_putAttachment(doc.follow_up,
url + doc.follow_up + "/SupportRequest_close", {});
});
}) })
.push(function () { .push(function () {
return gadget.redirect({"command": "change", return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'})
"options": {"jio_key": gadget.state.jio_key, .push(function () {
"page": "slap_controller"}}); // 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"}});
});
}); });
}) })
...@@ -60,11 +66,6 @@ ...@@ -60,11 +66,6 @@
"Close:", "Close:",
"Your Close Message", "Your Close Message",
"Include your close message", "Include your close message",
"Source",
"Follow up",
"Portal Type",
"Web Message",
"Parent Relative Url",
"Close Ticket" "Close Ticket"
]; ];
gadget.state.jio_key = options.jio_key; gadget.state.jio_key = options.jio_key;
...@@ -73,20 +74,19 @@ ...@@ -73,20 +74,19 @@
.push(function () { .push(function () {
return RSVP.all([ return RSVP.all([
gadget.getDeclaredGadget('form_view'), gadget.getDeclaredGadget('form_view'),
gadget.getSetting('me'),
gadget.jio_get(gadget.state.jio_key), gadget.jio_get(gadget.state.jio_key),
gadget.getTranslationList(translation_list) gadget.getTranslationList(translation_list)
]); ]);
}) })
.push(function (result) { .push(function (result) {
page_title_translation = result[3][10]; page_title_translation = result[2][5];
return result[0].render({ return result[0].render({
erp5_document: { erp5_document: {
"_embedded": {"_view": { "_embedded": {"_view": {
"my_title": { "my_title": {
"description": result[3][0], "description": result[2][0],
"title": result[3][1], "title": result[2][1],
"default": result[3][2] + " " + result[2].title, "default": result[2][2] + " " + result[1].title,
"css_class": "", "css_class": "",
"required": 1, "required": 1,
"editable": 1, "editable": 1,
...@@ -95,8 +95,8 @@ ...@@ -95,8 +95,8 @@
"type": "StringField" "type": "StringField"
}, },
"my_text_content": { "my_text_content": {
"description": result[3][3], "description": result[2][3],
"title": result[3][4], "title": result[2][4],
"default": "", "default": "",
"css_class": "", "css_class": "",
"required": 1, "required": 1,
...@@ -104,50 +104,6 @@ ...@@ -104,50 +104,6 @@
"key": "text_content", "key": "text_content",
"hidden": 0, "hidden": 0,
"type": "TextAreaField" "type": "TextAreaField"
},
"my_source": {
"description": "",
"title": result[3][5],
"default": result[1],
"css_class": "",
"required": 1,
"editable": 1,
"key": "source",
"hidden": 1,
"type": "StringField"
},
"my_follow_up": {
"description": "",
"title": result[3][6],
"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][7],
"default": "Web Message",
"css_class": "",
"required": 1,
"editable": 1,
"key": "portal_type",
"hidden": 1,
"type": "StringField"
},
"my_parent_relative_url": {
"description": "",
"title": result[3][9],
"default": "event_module",
"css_class": "",
"required": 1,
"editable": 1,
"key": "parent_relative_url",
"hidden": 1,
"type": "StringField"
} }
}}, }},
"_links": { "_links": {
...@@ -160,9 +116,7 @@ ...@@ -160,9 +116,7 @@
form_definition: { form_definition: {
group_list: [[ group_list: [[
"center", "center",
[["my_title"], ["my_text_content"], ["my_follow_up"], [["my_title"], ["my_text_content"]]
["my_portal_type"], ["my_parent_relative_url"],
["my_follow_up"], ["my_source"]]
]] ]]
} }
}); });
......
...@@ -263,7 +263,7 @@ ...@@ -263,7 +263,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>ERP5TypeTestCase</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -277,7 +277,7 @@ ...@@ -277,7 +277,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.11835.5812.36437</string> </value> <value> <string>1003.8785.37917.1416</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -295,7 +295,7 @@ ...@@ -295,7 +295,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1602260828.2</float> <float>1663870250.25</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
import json
portal = context.getPortalObject() portal = context.getPortalObject()
person = portal.portal_membership.getAuthenticatedMember().getUserValue() person = portal.portal_membership.getAuthenticatedMember().getUserValue()
if context.getPortalType() == "Support Request" and \ request = context.REQUEST
person.getRelativeUrl() == context.getDestinationDecision() and \ response = request.RESPONSE
context.getValidationState() != "invalidated":
context.invalidate() if person is None:
response.setStatus(403)
else:
request_kw = {
"event_title" : "Close: %s" % context.getTitle(),
"event_content": text_content,
"event_source": person.getRelativeUrl()
}
context.requestEvent(**request_kw)
if context.getPortalType() == "Support Request" and \
context.getSimulationState() != "invalidated":
context.invalidate()
event_relative_url = request.get('event_relative_url')
response.setHeader('Content-Type', "application/json")
return json.dumps({
"relative_url": event_relative_url
})
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>text_content</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
......
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