Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Leo Le Bouter
erp5
Commits
e708e403
Commit
e708e403
authored
Feb 23, 2018
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_hal_json_style]: Copy Workflow_statusModify from erp5_xhtml_style
parent
0cc8cf7b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
167 additions
and
0 deletions
+167
-0
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Workflow_statusModify.py
...portal_skins/erp5_hal_json_style/Workflow_statusModify.py
+105
-0
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Workflow_statusModify.xml
...ortal_skins/erp5_hal_json_style/Workflow_statusModify.xml
+62
-0
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Workflow_statusModify.py
0 → 100644
View file @
e708e403
from
Products.CMFCore.WorkflowCore
import
WorkflowException
from
Products.Formulator.Errors
import
FormValidationError
from
Products.DCWorkflow.DCWorkflow
import
ValidationFailed
from
Products.ERP5Type.Message
import
translateString
from
Products.ERP5Type.Log
import
log
portal
=
context
.
getPortalObject
()
request
=
kw
.
get
(
"REQUEST"
,
None
)
or
context
.
REQUEST
form
=
getattr
(
context
,
dialog_id
)
# Validate the form
try
:
# It is necessary to force editable_mode before validating
# data. Otherwise, field appears as non editable.
# This is the pending of form_dialog.
editable_mode
=
request
.
get
(
'editable_mode'
,
1
)
request
.
set
(
'editable_mode'
,
1
)
form
.
validate_all_to_request
(
request
)
request
.
set
(
'editable_mode'
,
editable_mode
)
except
FormValidationError
,
validation_errors
:
# Pack errors into the request
field_errors
=
form
.
ErrorFields
(
validation_errors
)
request
.
set
(
'field_errors'
,
field_errors
)
return
context
.
Base_renderForm
(
dialog_id
)
# XXX: this is a duplication from form validation code in Base_callDialogMethod
# Correct fix is to factorise this script with Base_callDialogMethod, not to
# fix XXXs here.
doaction_param_list
=
{}
MARKER
=
[]
for
f
in
form
.
get_fields
():
k
=
f
.
id
v
=
getattr
(
request
,
k
,
MARKER
)
if
v
is
not
MARKER
:
if
k
.
startswith
(
'your_'
):
k
=
k
[
5
:]
elif
k
.
startswith
(
'my_'
):
# compat
k
=
k
[
3
:]
doaction_param_list
[
k
]
=
v
listbox
=
request
.
get
(
'listbox'
)
# XXX: hardcoded field name
if
listbox
is
not
None
:
listbox_line_list
=
[]
for
key
,
value
in
sorted
(
listbox
.
iteritems
()):
value
[
'listbox_key'
]
=
key
listbox_line_list
.
append
(
value
)
doaction_param_list
[
'listbox'
]
=
tuple
(
listbox_line_list
)
execution_date
=
doaction_param_list
.
pop
(
'execution_date'
,
None
)
if
execution_date
is
not
None
:
context
.
activate
(
activity
=
'SQLQueue'
,
at_date
=
execution_date
,
).
Base_workflowStatusModify
(
workflow_action
=
doaction_param_list
.
pop
(
'next_workflow_action'
),
comment
=
doaction_param_list
.
get
(
'comment'
,
''
),
batch
=
True
,
)
doaction_param_list
[
'comment'
]
=
translateString
(
'Scheduled for execution at $time'
,
mapping
=
{
'time'
:
str
(
execution_date
),
},
)
try
:
portal
.
portal_workflow
.
doActionFor
(
context
,
doaction_param_list
[
'workflow_action'
],
**
doaction_param_list
)
except
ValidationFailed
,
error_message
:
if
getattr
(
error_message
,
'msg'
,
None
):
# use of Message class to store message+mapping+domain
message
=
error_message
.
msg
if
same_type
(
message
,
[]):
message
=
'. '
.
join
(
'%s'
%
x
for
x
in
message
)
else
:
message
=
str
(
message
)
else
:
message
=
str
(
error_message
)
if
len
(
message
)
>
2000
:
# too long message will generate a too long URI
# that would become an error.
log
(
"Status message has been truncated"
)
message
=
"%s ..."
%
message
[:(
2000
-
4
)]
except
WorkflowException
as
error_message
:
if
str
(
error_message
)
==
"No workflow provides the '${action_id}' action."
:
message
=
translateString
(
"Workflow state may have been updated by other user. Please try again."
)
return
context
.
Base_redirect
(
form_id
,
keep_items
=
{
'portal_status_message'
:
message
},
**
kw
)
else
:
raise
else
:
message
=
request
.
get
(
'portal_status_message'
)
if
message
is
None
:
message
=
translateString
(
'Status changed.'
)
kw
.
clear
()
# useful ?
# Allow to redirect to another document
redirect_document_path
=
request
.
get
(
'redirect_document_path'
,
None
)
if
redirect_document_path
:
redirect_document
=
portal
.
restrictedTraverse
(
redirect_document_path
)
form_id
=
'view'
else
:
redirect_document
=
context
return
redirect_document
.
Base_redirect
(
form_id
,
keep_items
=
{
'portal_status_message'
:
message
},
**
kw
)
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Workflow_statusModify.xml
0 → 100644
View file @
e708e403
<?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>
form_id, dialog_id, **kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Workflow_statusModify
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment