Commit b0f6e88c authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_travel_expense: Workflow transition display comments in application

parent 2cbcad20
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_jio_view</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_jio_view</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>jio_view</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>100.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>View</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Person_jio_view</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Discussion</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="handlebars.js"></script>
<script src="alertify.js"></script>
<script class="discussion-template" type="text/x-handlebars-template">
<div>
<pre>{{content}}</pre>
{{#if can_add_discussion}}
<div class="ui-header">
<div>
<textarea></textarea>
<button name="submit" type="submit" class="responsive ui-btn ui-icon-comment ui-btn-icon-left ui-corner-all ui-shadow-inset">Post Answer</button>
</div>
</div>
{{/if}}
</div>
</script>
<script src="gadget_officejs_jio_text_post.js"></script>
</head>
<body>
<form></form>
</body>
</html>
/*globals window, rJS, RSVP*/
/*jslint indent: 2, nomen: true, maxlen: 80*/
(function (window, RSVP, rJS, loopEventListener, Handlebars) {
"use strict";
var waiting_icon = "responsive ui-btn ui-icon-spinner ui-icon-spin ui-btn-icon-left ui-corner-all ui-shadow-inset ui-disabled",
gadget_klass = rJS(window),
source = gadget_klass.__template_element.querySelector(".discussion-template").innerHTML,
template = Handlebars.compile(source);
gadget_klass
.declareAcquiredMethod('post', 'jio_post')
.declareAcquiredMethod('put', 'jio_put')
.declareAcquiredMethod("repair", "jio_repair")
.declareAcquiredMethod("allDocs", "jio_allDocs")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("remove", "jio_remove")
.declareMethod("render", function (options) {
var gadget = this;
gadget.options = options;
return gadget.allDocs({
query: 'portal_type: Person' ,
select_list: ['first_name', 'last_name'],
limit: [0, 1]
})
.push(function (result) {
var i,
content = '',
transition_comment = {};
gadget.author = result.data.rows[0].value.first_name + ' ' + result.data.rows[0].value.last_name;
if (options.doc.transition_comment) {
transition_comment = JSON.parse(options.doc.transition_comment);
}
for (i in transition_comment) {
content += transition_comment[i].time + ' ';
content += transition_comment[i].actor + ': ';
content += transition_comment[i].comment + '\n';
}
gadget.transition_comment = transition_comment;
return template({
content: content,
can_add_discussion: options.can_add_discussion
});
})
.push(function (html) {
gadget.element.querySelector('form').innerHTML = html;
});
})
.declareService(function () {
var gadget = this,
submit = gadget.element.querySelector('button'),
form = gadget.element.querySelector('form');
if (gadget.options.can_add_discussion) {
return loopEventListener(
form,
'submit',
false,
function () {
var len = Object.keys(gadget.transition_comment).length,
tmp;
gadget.transition_comment[len] = {
'actor': gadget.author,
'time': new Date().toISOString().slice(0, 10),
'comment': gadget.element.querySelector('textarea').value
};
gadget.options.doc.state = 'Opened';
gadget.options.doc.transition_comment = JSON.stringify(gadget.transition_comment);
submit.className = waiting_icon;
return gadget.post(gadget.options.doc)
.push(function () {
/*
modify data will change hash code,
which jio will try to push localmodify to erp5
gadget.options.doc.simulation_state = 'delivered';
return gadget.put(gadget.options.jio_key, gadget.options.doc);
*/
return gadget.remove(gadget.options.jio_key);
})
.push(function () {
return gadget.repair();
})
.push(function () {
return gadget.redirect({page: gadget.options.page});
});
});
}
});
}(window, RSVP, rJS, loopEventListener, Handlebars));
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>contributor/person_module/2</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_officejs_jio_text_post.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_hr_add_comment_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>OfficeJS Jio Text Post Js</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<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>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1483631237.36</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.40065.53190.1553</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1484312482.87</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
......@@ -35,12 +35,10 @@
<div name="state">{{state}}</div>
</div>
{{#if not_readonly}}
<div class="ui-field-contain">
<label data-i18n="Description">Description</label>
<textarea name="comment">{{comment}}</textarea>
</div>
<div class="ui-field-contain">
<label data-i18n="Total Price">Total Price</label>
<input type="number" name="quantity" value="{{quantity}}" step="0.01" required>
......@@ -123,7 +121,6 @@
<label for="sync_flag_no" data-i18n="Do Not Sync">Do Not Sync</label>
</div>
</div>
{{else}}
<div class="ui-field-contain">
<label data-i18n="Description">Description</label>
......@@ -192,10 +189,13 @@
</div>
</div>
{{/if}}
<div class="ui-field-contain">
<label data-i18n="Discussion">Discussion</label>
<div class='discussion'>
</div>
</div>
<div id="myModal" class="modal">
<span class="close">&times;</span>
<img class="modal-content" id="img01" name="img01">
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.9748.40508.8396</string> </value>
<value> <string>956.40028.61290.1433</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1482499947.59</float>
<float>1484312287.56</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -316,8 +316,19 @@
return template(ops);
})
.push(function (html) {
var discussion_div;
gadget.props.element.innerHTML = html;
discussion_div = gadget.props.element.querySelector('.discussion');
return gadget.declareGadget('gadget_officejs_jio_text_post.html', {element: discussion_div})
.push(function (discussion_gadget) {
options.page = 'expense_record_list';
if (["Closed", "Suspended"].indexOf(options.doc.state) !== -1) {
options.can_add_discussion = true;
}
return discussion_gadget.render(options);
});
})
.push(function () {
return gadget.updateHeader({
title: gadget.options.jio_key + " " + (gadget.options.doc.record_revision || 1),
save_action: sync_state === 'Synced'? false: true
......
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.24261.36171.23790</string> </value>
<value> <string>956.40024.27967.8789</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -258,7 +258,7 @@
</tuple>
<state>
<tuple>
<float>1483434792.47</float>
<float>1484301997.49</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -97,7 +97,7 @@
args = {};
if (hash !== undefined) {
split = hash.split('?');
query = split[1] || "";
query = split[0] || "";
}
subhashes = query.split('&');
for (index in subhashes) {
......@@ -130,20 +130,18 @@
var regexp = /^X-Delegate uri="(http[s]*:\/\/[\/\-\[\]{}()*+:?.,\\\^$|#\s\w%]+)"$/
var auth_page = error.target.getResponseHeader('WWW-Authenticate'),
site;
if (! auth_page) {
auth_page = window.location.href + 'hateoas/connection/login_form';
}
/* if (regexp.test(auth_page)) {
if (regexp.test(auth_page)) {
site = UriTemplate.parse(
regexp.exec(auth_page)[1]
).expand({
came_from: window.location.href,
came_from: window.location.href + "#{&n.me}",
cors_origin: window.location.origin,
});
}*/
}
if (auth_page) {
return gadget.redirect({ toExternal: true, url: auth_page});
if (site) {
return gadget.redirect({ toExternal: true, url: site});
}
}
......@@ -242,10 +240,17 @@
.declareMethod('createJio', function () {
var gadget = this,
logout_url_template,
tmp;
//localStorage.clear();
tmp = hashParams(),
hateoas_url,
default_view,
me;
me = tmp['n.me'] || '';
return new RSVP.Queue()
.push(function () {
if (me) {
return gadget.setSetting('me', me);
}
})
.push(function () {
return RSVP.all([
gadget.getSetting('hateoas_url'),
......@@ -254,15 +259,30 @@
]);
})
.push(function (setting_list) {
var me = setting_list[2],
current_date = new Date(),
var jio_storage;
hateoas_url = setting_list[0];
default_view = setting_list[1];
me = setting_list[2];
if (!me) {
jio_storage = jIO.createJIO({
type: "erp5",
url: setting_list[0],
default_view_reference: setting_list[1]
});
return wrapJioCall(gadget, 'getAttachment', ['acl_users', hateoas_url, {format: "json"}], jio_storage)
.push(function (result) {
me = result._links.me.href;
return gadget.setSetting('me', me);
});
}
})
.push(function () {
var current_date = new Date(),
new_date = new Date(
current_date.getFullYear(),
current_date.getMonth(),
current_date.getDate() - 60
);
//office router can't handler me parameter
me = 'tmp';
gadget.state_parameter_dict.me = me;
//gadget.state_parameter_dict.authenticated = true;
gadget.state_parameter_dict.jio_storage = jIO.createJIO({
......@@ -291,14 +311,14 @@
type: "uuid",
sub_storage: {
type: "indexeddb",
database: "mmr-erp5-" + me
database: "mmr-erp5-tmp"
}
}
},
remote_sub_storage: {
type: "erp5",
url: setting_list[0],
default_view_reference: setting_list[1]
url: hateoas_url,
default_view_reference: default_view
}
});
gadget.state_parameter_dict.jio_storage.__storage._signature_sub_storage = jIO.createJIO({
......
......@@ -224,7 +224,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>supercedriclen</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.8685.14094.36198</string> </value>
<value> <string>956.45945.18260.25463</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1482921657.76</float>
<float>1484657302.88</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -62,7 +62,6 @@
</div>
</div>
{{/if}}
</form>
</script>
<script src="gadget_officejs_jio_leave_request_record_view.js"></script>
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>955.41038.59829.61593</string> </value>
<value> <string>956.37052.29099.3498</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1480517010.98</float>
<float>1484240093.48</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -217,7 +217,6 @@
})
.push(function (html) {
gadget.props.element.innerHTML = html;
return gadget.updateHeader({
title: "Demande de congé",
save_action: sync_state === 'Synced'? false: true
......
......@@ -244,7 +244,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.17061.57868.19302</string> </value>
<value> <string>956.38999.14763.58112</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>1482923877.99</float>
<float>1484240163.15</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -78,6 +78,11 @@
</div>
</div>
{{/if}}
<div class="ui-field-contain">
<label data-i18n="Discussion">Discussion</label>
<div class='discussion'>
</div>
</div>
</form>
</script>
<script src="gadget_officejs_jio_travel_request_record_view.js"></script>
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>955.52776.55364.53777</string> </value>
<value> <string>956.38978.20050.22596</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1481299568.88</float>
<float>1484301861.21</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -178,6 +178,7 @@
} else {
not_sync_checked = 'checked';
}
ops = {
select_options: select_options,
title: options.doc.title,
......@@ -198,8 +199,19 @@
return template(ops);
})
.push(function (html) {
var discussion_div;
gadget.props.element.innerHTML = html;
discussion_div = gadget.props.element.querySelector('.discussion');
return gadget.declareGadget('gadget_officejs_jio_text_post.html', {element: discussion_div})
.push(function (discussion_gadget) {
options.page = 'travel_request_record_list';
if (["Closed", "Suspended"].indexOf(options.doc.state) !== -1) {
options.can_add_discussion = true;
}
return discussion_gadget.render(options);
});
})
.push(function () {
return gadget.updateHeader({
title: gadget.options.jio_key + " " + (gadget.options.doc.record_revision || 1),
save_action: sync_state === 'Synced'? false: true
......
......@@ -244,7 +244,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.15594.34393.18107</string> </value>
<value> <string>956.40024.39635.59818</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>1482836213.38</float>
<float>1484301994.5</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -200,6 +200,26 @@
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_login</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_logout</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
......@@ -247,6 +267,14 @@
<none/>
</value>
</item>
<item>
<key> <string>configuration_login</string> </key>
<value> <string>connection/login_form{?came_from}</string> </value>
</item>
<item>
<key> <string>configuration_logout</string> </key>
<value> <string>connection/WebSite_logout{?came_from}</string> </value>
</item>
<item>
<key> <string>container_layout</string> </key>
<value> <string>ERP5Document_getHateoas</string> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>transition_comment_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>transition_comment_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
import json
portal = context.getPortalObject()
record = context
def byteify(string):
if isinstance(string, dict):
tmp = {}
for key, value in string.iteritems():
tmp[byteify(key)] = byteify(value)
return tmp
elif isinstance(string, list):
return [byteify(element) for element in string]
elif isinstance(string, unicode):
return string.encode('utf-8')
else:
return string
if record.getDestinationReference() is not None:
ticket_brain_list = portal.portal_catalog(
portal_type="Expense Validation Request",
......@@ -16,6 +30,8 @@ else:
follow_up_ticket_type="Expense Validation Request",
)
ticket = record.getFollowUpValue()
if portal.portal_workflow.isTransitionPossible(ticket, 'validate'):
ticket.validate()
record.setDestinationReference(ticket.getReference())
record.setFollowUpValue(ticket)
......@@ -26,6 +42,17 @@ if related_mission_url:
source_project_url = travel_request.getFollowUp()
else:
source_project_url = ""
new_transition_comment = record.getTransitionComment()
if new_transition_comment is not None:
new_transition_comment = byteify(json.loads(new_transition_comment))
old_transition_comment = byteify(json.loads(ticket.Ticket_generateTransitionAndCommentList(listbox_view=False)))
for attr in new_transition_comment:
if attr not in old_transition_comment:
context.log(new_transition_comment)
context.log(old_transition_comment)
if portal.portal_workflow.isTransitionPossible(ticket, 'validate'):
ticket.validate(comment=new_transition_comment[attr]['comment'], actor=new_transition_comment[attr]['actor'])
ticket.edit(
title=record.getTitle(),
resource=record.getType(),
......
......@@ -96,6 +96,8 @@
<string>my_related_mission</string>
<string>my_type</string>
<string>my_type_title</string>
<string>my_transition_comment</string>
<string>my_destination_reference</string>
</list>
</value>
</item>
......
......@@ -11,10 +11,17 @@ if not record_relative_url:
elif len(record_brain_list) == 0:
return
record= record_brain_list[0].getObject()
#XXX Record_archivePreviousVersions deliver this record, but may not index yet
if record.getSimulationState() != 'stopped':
return
# XXX to be finished
else:
record = portal.restrictedTraverse(record_relative_url)
new_record = record.Base_createCloneDocument(batch_mode=True)
new_record.edit(
title=context.getTitle(),
......@@ -32,6 +39,6 @@ new_record.edit(
type_title=context.getResourceTitle(),
)
new_record.setPhotoData(None)
new_record.setTransitionComment(context.Ticket_generateTransitionAndCommentList(listbox_view=False))
new_record.stop()
new_record.Record_archivePreviousVersions()
import json
portal = context.getPortalObject()
record = context
def byteify(string):
if isinstance(string, dict):
tmp = {}
for key, value in string.iteritems():
tmp[byteify(key)] = byteify(value)
return tmp
elif isinstance(string, list):
return [byteify(element) for element in string]
elif isinstance(string, unicode):
return string.encode('utf-8')
else:
return string
if record.getDestinationReference() is not None:
ticket_brain_list = portal.portal_catalog(
portal_type="Travel Request",
......@@ -16,11 +31,25 @@ else:
follow_up_ticket_type="Travel Request",
)
ticket = record.getFollowUpValue()
if portal.portal_workflow.isTransitionPossible(ticket, 'validate'):
ticket.validate()
record.setDestinationReference(ticket.getReference())
record.setFollowUpValue(ticket)
new_transition_comment = record.getTransitionComment()
if new_transition_comment is not None:
new_transition_comment = byteify(json.loads(new_transition_comment))
old_transition_comment = byteify(json.loads(ticket.Ticket_generateTransitionAndCommentList(listbox_view=False)))
for attr in new_transition_comment:
if attr not in old_transition_comment:
context.log(new_transition_comment)
context.log(old_transition_comment)
if portal.portal_workflow.isTransitionPossible(ticket, 'validate'):
ticket.validate(comment=new_transition_comment[attr]['comment'], actor=new_transition_comment[attr]['actor'])
ticket.edit(
title=record.getTitle(),
resource=record.getResource(),
......
......@@ -92,6 +92,8 @@
<string>my_site</string>
<string>my_destination_node_title</string>
<string>your_state</string>
<string>my_transition_comment</string>
<string>my_destination_reference</string>
</list>
</value>
</item>
......
......@@ -11,6 +11,9 @@ if not record_relative_url:
elif len(record_brain_list) == 0:
return
record= record_brain_list[0].getObject()
#XXX Record_archivePreviousVersions deliver this record, but may not index yet
if record.getSimulationState() != 'stopped':
return
# XXX to be finished
else:
record = portal.restrictedTraverse(record_relative_url)
......@@ -30,4 +33,5 @@ new_record.edit(
)
new_record.stop()
new_record.setTransitionComment(context.Ticket_generateTransitionAndCommentList(listbox_view=False))
new_record.Record_archivePreviousVersions()
......@@ -75,7 +75,7 @@
<key> <string>bottom</string> </key>
<value>
<list>
<string>listbox</string>
<string>listbox_comment</string>
</list>
</value>
</item>
......@@ -112,6 +112,7 @@
<string>my_source_project_title</string>
<string>my_destination_title</string>
<string>my_assessment_form_id</string>
<string>listbox_comment_time</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>columns</string>
<string>count_method</string>
<string>description</string>
<string>editable</string>
<string>editable_columns</string>
<string>list_method</string>
<string>portal_types</string>
<string>sort</string>
<string>title</string>
<string>url_columns</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_comment</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>
<item>
<key> <string>target</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>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>columns</string> </key>
<value>
<list>
<tuple>
<string>actor</string>
<string>Actor</string>
</tuple>
<tuple>
<string>time</string>
<string>Time</string>
</tuple>
<tuple>
<string>comment</string>
<string>Comment</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>count_method</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>editable_columns</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_listbox</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>list_method</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>portal_types</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>sort</string> </key>
<value>
<list>
<tuple>
<string>time</string>
<string>ASC</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Comment</string> </value>
</item>
<item>
<key> <string>url_columns</string> </key>
<value>
<list>
<tuple>
<string>actor</string>
<string></string>
</tuple>
<tuple>
<string>time</string>
<string></string>
</tuple>
<tuple>
<string>comment</string>
<string></string>
</tuple>
</list>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Method" module="Products.Formulator.MethodField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>Ticket_generateTransitionAndCommentList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>
<string>date_only</string>
<string>editable</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_comment_time</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>
<item>
<key> <string>target</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>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>date_only</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_date</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Time</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
import json
transition_comment = {}
transition_comment_list = []
index = 0
item_list = context.Base_getWorkflowHistoryItemList(workflow_id = workflow_id)
for i in item_list:
comment = getattr(i, 'comment')
if comment:
action = getattr(i, 'action')
if action in ('Ask Question Action','Close Ticket Action','Open Ticket Action','Accept Ticket Acction', 'Open Ticket'):
if listbox_view:
transition_comment_list.append(i)
else:
transition_comment[index] = {
'actor': getattr(i, 'actor'),
'time': getattr(i, 'time').Date().replace('/','-'),
'comment': comment
}
index += 1
if listbox_view:
return transition_comment_list
return json.dumps(transition_comment)
<?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>workflow_id = \'ticket_acceptance_simulation_workflow\', listbox_view=\'true\', **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Ticket_generateTransitionAndCommentList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<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/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Workflow_statusModify</string> </value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>your_comment</string>
<string>your_workflow_action</string>
</list>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Ticket_viewWorkflowActionDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Base_viewWorkflowActionDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Validate Workflow Action</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -74,7 +74,9 @@
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
<list>
<string>listbox_comment</string>
</list>
</value>
</item>
<item>
......@@ -94,6 +96,7 @@
<string>my_price</string>
<string>my_price_currency</string>
<string>my_total_price</string>
<string>listbox_comment_time</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>columns</string>
<string>count_method</string>
<string>description</string>
<string>editable</string>
<string>editable_columns</string>
<string>list_method</string>
<string>portal_types</string>
<string>sort</string>
<string>title</string>
<string>url_columns</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_comment</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>
<item>
<key> <string>target</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>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>columns</string> </key>
<value>
<list>
<tuple>
<string>actor</string>
<string>Actor</string>
</tuple>
<tuple>
<string>time</string>
<string>Time</string>
</tuple>
<tuple>
<string>comment</string>
<string>Comment</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>count_method</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>editable_columns</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_listbox</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>list_method</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>portal_types</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>sort</string> </key>
<value>
<list>
<tuple>
<string>time</string>
<string>ASC</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Comment</string> </value>
</item>
<item>
<key> <string>url_columns</string> </key>
<value>
<list>
<tuple>
<string>actor</string>
<string></string>
</tuple>
<tuple>
<string>time</string>
<string></string>
</tuple>
<tuple>
<string>comment</string>
<string></string>
</tuple>
</list>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Method" module="Products.Formulator.MethodField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>Ticket_generateTransitionAndCommentList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>
<string>date_only</string>
<string>editable</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_comment_time</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>
<item>
<key> <string>target</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>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>date_only</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_date</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Time</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -10,13 +10,17 @@
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string>Close Ticket</string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string>%(content_url)s/Base_viewWorkflowActionDialog?workflow_action=invalidate_action</string> </value>
<value> <string>%(content_url)s/Ticket_viewWorkflowActionDialog?workflow_action=invalidate_action</string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
......@@ -57,10 +61,7 @@
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="Guard" module="Products.DCWorkflow.Guard"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
......
......@@ -16,11 +16,11 @@
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string>Suspend Ticket</string> </value>
<value> <string>Ask Question</string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string>%(content_url)s/Base_viewWorkflowActionDialog?workflow_action=suspend_action</string> </value>
<value> <string>%(content_url)s/Ticket_viewWorkflowActionDialog?workflow_action=suspend_action</string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Suspend Ticket Action</string> </value>
<value> <string>Ask Question Action</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
......
......@@ -56,6 +56,12 @@
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>var_exprs</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
......@@ -76,4 +82,39 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>actor</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python:state_change.kwargs.get(\'actor\') if state_change.kwargs.get(\'actor\') else user.getIdOrUserName()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -10,6 +10,7 @@ Expense Validation Request | view
Leave Request Record | jio_view
Leave Request Record | view
Leave Request | records
Person | jio_view
Record Module | view
Service | jio_view
System Preference | hr_preference
......
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