Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush Tiwari
erp5
Commits
fc24e53e
Commit
fc24e53e
authored
Oct 06, 2017
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_config: Add function to get patch object and create displayable diff
parent
0436c8e4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
10 deletions
+32
-10
product/ERP5/Document/BusinessManager.py
product/ERP5/Document/BusinessManager.py
+32
-10
No files found.
product/ERP5/Document/BusinessManager.py
View file @
fc24e53e
...
@@ -1195,12 +1195,12 @@ class BusinessPatchItem(XMLObject):
...
@@ -1195,12 +1195,12 @@ class BusinessPatchItem(XMLObject):
# Business Property Item for storing old and new values
# Business Property Item for storing old and new values
if
'#'
in
item_path
:
if
'#'
in
item_path
:
# Create new_prop_item and build it from ZODB
# Create new_prop_item and build it from ZODB
new_
prop_
item
=
self
.
newContent
(
portal_type
=
'Business Property Item'
,
new_item
=
self
.
newContent
(
portal_type
=
'Business Property Item'
,
item_path
=
item_path
,
item_path
=
item_path
,
item_layer
=
item_layer
,
item_layer
=
item_layer
,
item_sign
=
item_sign
,
item_sign
=
item_sign
,
id
=
'new_item'
)
id
=
'new_item'
)
new_
prop_
item
.
build
(
self
)
new_item
.
build
(
self
)
else
:
else
:
# Create new_item and build it from ZODB
# Create new_item and build it from ZODB
...
@@ -1214,6 +1214,15 @@ class BusinessPatchItem(XMLObject):
...
@@ -1214,6 +1214,15 @@ class BusinessPatchItem(XMLObject):
updated_id
=
'old_item'
updated_id
=
'old_item'
# Copy old item/property item from the item at similar path in dependency_bm
# Copy old item/property item from the item at similar path in dependency_bm
dependency_item
=
dependency_bm
.
getBusinessItemByPath
(
item_path
)
dependency_item
=
dependency_bm
.
getBusinessItemByPath
(
item_path
)
# Raise if there is no item exisiting in dependency Business Manager
if
not
dependency_item
:
import
pdb
;
pdb
.
set_trace
()
raise
ValueError
(
'No %s exist at path %s in installed version of %s'
%
(
new_item
.
getPortalType
(),
item_path
,
dependency_title
,))
cp_data
=
dependency_bm
.
manage_copyObjects
([
dependency_item
.
getId
()])
cp_data
=
dependency_bm
.
manage_copyObjects
([
dependency_item
.
getId
()])
new_id
=
self
.
manage_pasteObjects
(
cp_data
)[
0
][
'new_id'
]
new_id
=
self
.
manage_pasteObjects
(
cp_data
)[
0
][
'new_id'
]
self
.
manage_renameObject
(
id
=
new_id
,
new_id
=
updated_id
)
self
.
manage_renameObject
(
id
=
new_id
,
new_id
=
updated_id
)
...
@@ -1246,25 +1255,38 @@ class BusinessPatchItem(XMLObject):
...
@@ -1246,25 +1255,38 @@ class BusinessPatchItem(XMLObject):
else
:
else
:
return
old_item
.
getProperty
(
'item_property_value'
)
return
old_item
.
getProperty
(
'item_property_value'
)
def
getDiff
(
self
):
def
getDiff
(
self
,
patch_format
=
'deepdiff'
):
"""
"""
Use diff tool to find the diff between two values
Use diff tool to find the diff between two values
XXX: For now we display the json format of the patched diff
XXX: For now we display the json format of the patched diff
"""
"""
portal
=
self
.
getPortalObject
()
patch
=
self
.
getPatchObject
(
patch_format
)
diff_tool
=
portal
.
portal_diff
patch_format
=
'deepdiff'
patch
=
diff_tool
.
diffPortalObject
(
old
=
self
.
_getOb
(
'old_item'
),
new
=
self
.
_getOb
(
'new_item'
),
patch_format
=
patch_format
)
if
patch_format
==
'deepdiff'
:
if
patch_format
==
'deepdiff'
:
return
patch
.
asDeepDiffPatch
().
json
return
patch
.
asDeepDiffPatch
().
json
else
:
else
:
# For json-patch object
# For json-patch object
return
patch
.
asJSONPatch
().
to_string
()
return
patch
.
asJSONPatch
().
to_string
()
def
getPatchObject
(
self
,
patch_format
=
'deepdiff'
):
portal
=
self
.
getPortalObject
()
diff_tool
=
portal
.
portal_diff
old_item
=
self
.
_getOb
(
'old_item'
)
new_item
=
self
.
_getOb
(
'new_item'
)
if
(
old_item
.
getPortalType
()
==
new_item
.
getPortalType
()
==
'Business Item'
):
old
=
old_item
.
objectValues
()[
0
]
new
=
new_item
.
objectValues
()[
0
]
else
:
old
=
old_item
.
getProperty
(
'item_property_value'
)
new
=
new_item
.
getProperty
(
'item_property_value'
)
patch
=
diff_tool
.
diffPortalObject
(
old
=
old
,
new
=
new
,
patch_format
=
patch_format
)
return
patch
def
registerSkinFolder
(
skin_tool
,
skin_folder
):
def
registerSkinFolder
(
skin_tool
,
skin_folder
):
request
=
skin_tool
.
REQUEST
request
=
skin_tool
.
REQUEST
# XXX: Getting parameter from request instead of dialog is bad
# XXX: Getting parameter from request instead of dialog is bad
...
...
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