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
5eac0483
Commit
5eac0483
authored
Sep 27, 2018
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_core]: Add functions for property history in ZODB History component
parent
95352144
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
1 deletion
+50
-1
product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.ZODBHistory.py
...plateItem/portal_components/extension.erp5.ZODBHistory.py
+50
-1
No files found.
product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.ZODBHistory.py
View file @
5eac0483
...
...
@@ -28,6 +28,8 @@
#
##############################################################################
from
DateTime
import
DateTime
from
OFS.History
import
historicalRevision
from
Products.ERP5Type.Log
import
log
def
_parseCategory
(
category
):
if
category
is
None
or
category
.
find
(
'/'
)
<
0
:
...
...
@@ -110,7 +112,8 @@ def getChangeHistoryList(document, size=50, attribute_name=None):
current_state
=
connection
.
oldstate
(
document
,
d_
[
'tid'
])
changes
=
{}
current_datetime
=
toDateTime
(
d_
[
'time'
])
record
=
{
'datetime'
:
current_datetime
,
record
=
{
'serial'
:
d_
[
'tid'
],
'datetime'
:
current_datetime
,
'user'
:
d_
[
'user_name'
],
'action'
:
d_
[
'description'
],
'changes'
:
changes
...
...
@@ -140,6 +143,49 @@ def getChangeHistoryList(document, size=50, attribute_name=None):
return
history
def
getChangeHistoryListDiffFormat
(
document
,
size
=
50
,
attribute_name
=
None
):
"""
Returns ZODB History in the format which can be used to create diff,
i.e, just follow the basic key value pair format of a python dictionary.
"""
connection
=
document
.
_p_jar
result
=
document
.
_p_jar
.
db
().
history
(
document
.
_p_oid
,
size
=
size
)
if
result
is
None
:
return
[]
result
=
list
(
reversed
(
result
))
history
=
[]
previous_state
=
None
for
d_
in
result
:
current_state
=
connection
.
oldstate
(
document
,
d_
[
'tid'
])
changes
=
{}
current_datetime
=
toDateTime
(
d_
[
'time'
])
record
=
{
'serial'
:
d_
[
'tid'
],
'datetime'
:
current_datetime
,
'user'
:
d_
[
'user_name'
],
'action'
:
d_
[
'description'
],
'changes'
:
changes
}
log
(
record
)
if
previous_state
is
None
:
previous_state
=
{}
for
key
in
current_state
:
if
key
.
startswith
(
'_'
)
or
key
==
'workflow_history'
:
continue
if
previous_state
.
get
(
key
)
!=
current_state
[
key
]:
changes
[
key
]
=
current_state
[
key
]
if
key
==
'categories'
:
for
cat
in
current_state
.
get
(
'categories'
,
()):
ck
,
cv
=
_parseCategory
(
cat
)
if
ck
in
changes
:
changes
[
ck
].
append
(
cv
)
else
:
changes
[
ck
]
=
[
cv
]
history
.
append
(
record
)
previous_state
=
current_state
return
history
def
getChangeHistoryListForProperty
(
document
,
property_name
,
size
=
50
,
...
...
@@ -168,6 +214,9 @@ def getChangeHistoryListForProperty(document,
return
property_change_list
def
getHistoricalRevisionFromSerial
(
document
,
serial
):
return
historicalRevision
(
document
,
serial
).
showDict
()
def
getHistoricalRevisionsDateList
(
document
,
size
=
50
):
"""
Returns the list dates in float format for the last
...
...
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