Commit 6f6ae98b authored by Rafael Monnerat's avatar Rafael Monnerat

Fixup add Message into a Ticket

See merge request !396
parents e28ae98e 09177e2a
Pipeline #22511 failed with stage
in 0 seconds
......@@ -5,7 +5,7 @@
</chain>
<chain>
<type>Regularisation Request</type>
<workflow>edit_workflow, pricing_interaction_workflow, ticket_interaction_workflow, ticket_workflow</workflow>
<workflow>edit_workflow, pricing_interaction_workflow, ticket_interaction_workflow, ticket_slap_interface_workflow, ticket_workflow</workflow>
</chain>
<chain>
<type>Support Request</type>
......
......@@ -97,6 +97,8 @@ class TestSlapOSCoreTicketSlapInterfaceWorkflow(SlapOSTestCaseMixin):
self.assertRaises(TypeError, self.support_request.requestEvent)
self.assertRaises(TypeError, self.support_request.requestEvent, event_title="A")
self.assertRaises(TypeError, self.support_request.requestEvent, event_content="A")
self.assertRaises(TypeError, self.support_request.requestEvent, event_source="A")
def test_SupportRequest_requestEvent(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
......@@ -109,8 +111,8 @@ class TestSlapOSCoreTicketSlapInterfaceWorkflow(SlapOSTestCaseMixin):
self.support_request.requestEvent(
event_title="A",
event_content="B"
)
event_content="B",
event_source=person.getRelativeUrl())
self.tic()
event_relative_url = self.support_request.REQUEST.get("event_relative_url")
......
......@@ -6,12 +6,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSCloudTicketSlapInterfaceWorkflow</string> </value>
......@@ -61,28 +55,13 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -95,7 +74,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -104,7 +83,7 @@
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
......
......@@ -36,7 +36,8 @@ ticket.setStartDate(DateTime())
ticket.requestEvent(
event_title=ticket.getTitle(),
event_content=ticket.getDescription()
event_content=ticket.getDescription(),
event_source=ticket.getDestinationDecision()
)
event_relative_url = context.REQUEST.get("event_relative_url")
......
......@@ -9,14 +9,15 @@ kwargs = state_change.kwargs
try:
title = kwargs['event_title']
text_content = kwargs['event_content']
source = kwargs['event_source']
except KeyError:
raise TypeError, "Ticket_requestEvent takes exactly 2 argument"
raise TypeError, "Ticket_requestEvent takes at exactly 3 argument"
web_message = portal.event_module.newContent(
portal_type="Web Message",
title=title,
text_content=text_content,
source=ticket.getDestinationDecision(),
source=source,
content_type="text/plain",
destination=ticket.getSource(),
resource=ticket.getResource(),
......
......@@ -3,5 +3,6 @@ Incident Response | ticket_workflow
Regularisation Request | edit_workflow
Regularisation Request | pricing_interaction_workflow
Regularisation Request | ticket_interaction_workflow
Regularisation Request | ticket_slap_interface_workflow
Regularisation Request | ticket_workflow
Support Request | ticket_slap_interface_workflow
\ No newline at end of file
......@@ -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 (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 (doc) {
return gadget.jio_post(doc);
/*.push(function (attachment) {
return jIO.util.readBlobAsText(attachment.target.response);
})
.push(function (response) {
return JSON.parse(response.target.result);
})*/
.push(function () {
return gadget.redirect({"command": "change",
"options": {"jio_key": gadget.state.jio_key,
"page": "slap_controller"}});
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"}});
});
});
})
......@@ -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>
......@@ -90,6 +90,12 @@
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td tal:content="python: here.Base_translateString('User Assigned', lang=lang)"></td>
<td></td>
</tr>
<tal:block tal:define="menu_action python: 'Add'">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/click_submenu_action" />
</tal:block>
......@@ -173,6 +179,13 @@
<td>TEST-SLAPOSJS-SUPPORT-REQUEST NEW MESSAGE</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td tal:content="python: here.Base_translateString('Operator Assigned', lang=lang)"></td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_logout" />
</tbody>
......
......@@ -157,6 +157,12 @@
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td tal:content="python: here.Base_translateString('Operator Assigned', lang=lang)"></td>
<td></td>
</tr>
<tal:block tal:define="menu_action python: 'Add'">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/click_submenu_action" />
</tal:block>
......@@ -240,6 +246,188 @@
<td>TEST-SLAPOSJS-SUPPORT-REQUEST NEW MESSAGE</td>
<td></td>
</tr>
<tal:block tal:define="menu_action python: 'Close'">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/click_submenu_action" />
</tal:block>
<tal:block tal:define="header python: 'Close Ticket'">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" />
</tal:block>
<tr>
<td>waitForElementPresent</td>
<td>//textarea[@id="text_content"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//textarea[@id="text_content"]</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>//textarea[@id="text_content"]</td>
<td>Closing Ticket</td>
</tr>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/click_proceed" />
<tal:block tal:define="header python: 'Support Request : ${title}';
dummy python: context.REQUEST.set('mapping', {'title': 'TEST-SLAPOSJS-SUPPORT-REQUEST 0'})">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_wait_for_activities_and_front_page" />
<tal:block define="menu_item python: 'Tickets'; header menu_item">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/access_menu_item" />
</tal:block>
<tal:block tal:define="pagination_configuration python: {'header': '(1)', 'footer': '${count} Records'};
dummy python: context.REQUEST.set('mapping', {'count': '1'})">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/check_listbox_pagination_text" />
</tal:block>
<tr>
<td>waitForElementPresent</td>
<td>//a[text()="TEST-SLAPOSJS-SUPPORT-REQUEST 0"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//a[text()="TEST-SLAPOSJS-SUPPORT-REQUEST 0"]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//a[text()="TEST-SLAPOSJS-SUPPORT-REQUEST 0"]</td>
<td></td>
</tr>
<tal:block tal:define="header python: 'Support Request : ${title}';
dummy python: context.REQUEST.set('mapping', {'title': 'TEST-SLAPOSJS-SUPPORT-REQUEST 0'})">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" />
</tal:block>
<tal:block tal:define="pagination_configuration python: {'header': '(3)', 'footer': '${count} Records'};
dummy python: context.REQUEST.set('mapping', {'count': '3'})">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/check_listbox_pagination_text" />
</tal:block>
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_slapos_event_discussion_entry.html')]//div[@class="slapos-event-discussion-message-header"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_slapos_event_discussion_entry.html')]//div[@class="slapos-event-discussion-message-header"]</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>Closing Ticket</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td tal:content="python: here.Base_translateString('Closed', lang=lang)"></td>
<td></td>
</tr>
<tal:block tal:define="menu_action python: 'Add'">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/click_submenu_action" />
</tal:block>
<tal:block tal:define="header python: 'New Message'">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" />
</tal:block>
<tr>
<td>waitForElementPresent</td>
<td>//textarea[@id="text_content"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//textarea[@id="text_content"]</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>//textarea[@id="text_content"]</td>
<td>TEST-SLAPOSJS-SUPPORT-REQUEST REOPEN</td>
</tr>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/click_proceed" />
<tal:block tal:define="header python: 'Support Request : ${title}';
dummy python: context.REQUEST.set('mapping', {'title': 'TEST-SLAPOSJS-SUPPORT-REQUEST 0'})">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_wait_for_activities_and_front_page" />
<tal:block define="menu_item python: 'Tickets'; header menu_item">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/access_menu_item" />
</tal:block>
<tal:block tal:define="pagination_configuration python: {'header': '(1)', 'footer': '${count} Records'};
dummy python: context.REQUEST.set('mapping', {'count': '1'})">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/check_listbox_pagination_text" />
</tal:block>
<tr>
<td>waitForElementPresent</td>
<td>//a[text()="TEST-SLAPOSJS-SUPPORT-REQUEST 0"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//a[text()="TEST-SLAPOSJS-SUPPORT-REQUEST 0"]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//a[text()="TEST-SLAPOSJS-SUPPORT-REQUEST 0"]</td>
<td></td>
</tr>
<tal:block tal:define="header python: 'Support Request : ${title}';
dummy python: context.REQUEST.set('mapping', {'title': 'TEST-SLAPOSJS-SUPPORT-REQUEST 0'})">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" />
</tal:block>
<tal:block tal:define="pagination_configuration python: {'header': '(4)', 'footer': '${count} Records'};
dummy python: context.REQUEST.set('mapping', {'count': '4'})">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/check_listbox_pagination_text" />
</tal:block>
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_slapos_event_discussion_entry.html')]//div[@class="slapos-event-discussion-message-header"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_slapos_event_discussion_entry.html')]//div[@class="slapos-event-discussion-message-header"]</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>TEST-SLAPOSJS-SUPPORT-REQUEST REOPEN</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td tal:content="python: here.Base_translateString('Operator Assigned', lang=lang)"></td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_logout" />
</tbody>
......
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