Commit b75ef7e9 authored by Romain Courteaud's avatar Romain Courteaud

slapos_jio: drop close ticket

parent ef3954d2
<!doctype html>
<html>
<!--
data-i18n=The name of a document in ERP5
data-i18n=Title
data-i18n=Close:
data-i18n=Your Close Message
data-i18n=Include your close message
data-i18n=Source
data-i18n=Follow up
data-i18n=Portal Type
data-i18n=Web Message
data-i18n=Parent Relative Url
data-i18n=Close Ticket
-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Add Text Document</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_slap_close_ticket.js"></script>
</head>
<body>
<form class="save_form ui-body-c" novalidate>
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right ui-screen-hidden"></button>
<div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="form_view"
data-gadget-sandbox="public">
</div>
</form>
</body>
</html>
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", "notifySubmitted")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.allowPublicAcquisition('notifySubmit', function () {
return this.triggerSubmit();
})
.onEvent('submit', function () {
var gadget = this;
return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
return RSVP.all([form_gadget.getContent(),
gadget.getSetting('hateoas_url')]);
})
.push(function (result) {
var doc = result[0],
url = result[1];
return gadget.jio_putAttachment(gadget.state.jio_key,
url + gadget.state.jio_key + "/SupportRequest_close",
{text_content: doc.text_content});
})
.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"}});
});
});
})
.declareMethod("triggerSubmit", function () {
return this.element.querySelector('button[type="submit"]').click();
})
.declareMethod("render", function (options) {
var gadget = this,
page_title_translation,
translation_list = [
"The name of a document in ERP5",
"Title",
"Close:",
"Your Close Message",
"Include your close message",
"Close Ticket"
];
gadget.state.jio_key = options.jio_key;
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getDeclaredGadget('form_view'),
gadget.jio_get(gadget.state.jio_key),
gadget.getTranslationList(translation_list)
]);
})
.push(function (result) {
page_title_translation = result[2][5];
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
"my_title": {
"description": result[2][0],
"title": result[2][1],
"default": result[2][2] + " " + result[1].title,
"css_class": "",
"required": 1,
"editable": 1,
"key": "title",
"hidden": 1,
"type": "StringField"
},
"my_text_content": {
"description": result[2][3],
"title": result[2][4],
"default": "",
"css_class": "",
"required": 1,
"editable": 1,
"key": "text_content",
"hidden": 0,
"type": "TextAreaField"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"center",
[["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'})
]);
})
.push(function (url_list) {
return gadget.updateHeader({
page_title: page_title_translation,
selection_url: url_list[0],
submit_action: true
});
});
});
}(window, rJS, RSVP));
\ No newline at end of file
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" : "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
})
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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>text_content</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Assignee</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SupportRequest_close</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -26,8 +26,6 @@ web_page_module/rjs_gadget_erp5_page_slap_all_invoice_list_html
web_page_module/rjs_gadget_erp5_page_slap_all_invoice_list_js
web_page_module/rjs_gadget_erp5_page_slap_certificate_login_view_html
web_page_module/rjs_gadget_erp5_page_slap_certificate_login_view_js
web_page_module/rjs_gadget_erp5_page_slap_close_ticket_html
web_page_module/rjs_gadget_erp5_page_slap_close_ticket_js
web_page_module/rjs_gadget_erp5_page_slap_compute_node_get_token_html
web_page_module/rjs_gadget_erp5_page_slap_compute_node_get_token_js
web_page_module/rjs_gadget_erp5_page_slap_compute_node_request_certificate_html
......
......@@ -26,8 +26,6 @@ web_page_module/rjs_gadget_erp5_page_slap_all_invoice_list_html
web_page_module/rjs_gadget_erp5_page_slap_all_invoice_list_js
web_page_module/rjs_gadget_erp5_page_slap_certificate_login_view_html
web_page_module/rjs_gadget_erp5_page_slap_certificate_login_view_js
web_page_module/rjs_gadget_erp5_page_slap_close_ticket_html
web_page_module/rjs_gadget_erp5_page_slap_close_ticket_js
web_page_module/rjs_gadget_erp5_page_slap_compute_node_get_token_html
web_page_module/rjs_gadget_erp5_page_slap_compute_node_get_token_js
web_page_module/rjs_gadget_erp5_page_slap_computer_network_view_html
......
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