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
alecs_myu
erp5
Commits
88877845
Commit
88877845
authored
Jun 14, 2018
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_core]: Add methods to get historical states in ZODBHistory
parent
dbfd4cf7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
2 deletions
+27
-2
product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.ZODBHistory.py
...plateItem/portal_components/extension.erp5.ZODBHistory.py
+27
-2
No files found.
product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.ZODBHistory.py
View file @
88877845
##############################################################################
##############################################################################
#
#
# Copyright (c) 201
4
Nexedi KK and Contributors. All Rights Reserved.
# Copyright (c) 201
8
Nexedi KK and Contributors. All Rights Reserved.
# Yusei Tahara <yusei@nexedi.com>
# Yusei Tahara <yusei@nexedi.com>
# Tatuya Kamada <tatuya@nexedi.com>
# Tatuya Kamada <tatuya@nexedi.com>
# Ayush Tiwari <ayush.tiwari@nexedi.com>
#
#
# WARNING: This program as such is intended to be used by professional
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# programmers who take the whole responsability of assessing all potential
...
@@ -138,3 +139,27 @@ def getChangeHistoryList(document, size=50, attribute_name=None):
...
@@ -138,3 +139,27 @@ def getChangeHistoryList(document, size=50, attribute_name=None):
history
.
sort
(
key
=
lambda
x
:
x
[
'datetime'
])
history
.
sort
(
key
=
lambda
x
:
x
[
'datetime'
])
return
history
return
history
def
getHistoricalRevisionsDateList
(
document
,
size
=
50
):
"""
Returns the list dates in float format for the last
50 versions of the document.
"""
result
=
document
.
_p_jar
.
db
().
history
(
document
.
_p_oid
,
size
)
return
[
d_
[
'time'
]
for
d_
in
result
]
def
getRevisionFromDate
(
document
,
date
,
size
=
50
):
"""
Returns the attribute/property dict of an object from its revision date
params:
date - It shold be in float format (or float converted to string)
size -- How long history do you need
"""
result
=
document
.
_p_jar
.
db
().
history
(
document
.
_p_oid
,
size
)
# Get the version of object using the date
result_obj
=
[
l
for
l
in
result
if
str
(
l
[
'time'
])
==
str
(
date
)][
0
]
# Return the history state of the object
connection
=
document
.
_p_jar
return
connection
.
oldstate
(
document
,
result_obj
[
'tid'
])
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