Package: imio.history
imio.historyManage object history using a table and highlight history link when necessaryThe goal is to be able to manage several histories for various needs on a content and display it together, merged in the same view.Adapters implementing theIImioHistoryinterfaceTo do this, we must ensure that the histories use same structure.  We base the work on theworkflow_history, though a custom history may have additional keys if necessary.The workflow_history could looks like :{'my_custom_workflow':({'action':None,'review_state':'private','actor':'user_id1','comments':'','time':DateTime('2018/03/27 09:51:55.303708 GMT+2')},{'action':'publish','review_state':'published','comments':'','actor':'user_id1','time':DateTime('2018/03/29 15:35:24.646745 GMT+2')},{'action':'retract','review_state':'private','comments':'My comments','actor':'admin','time':DateTime('2018/03/29 15:35:27.246169 GMT+2')})}Histories are made available thru a named adapter that implements theIImioHistoryinterface.By default, adapters are provided for theworkflow_history(ImioWfHistoryAdapter) and revisions history (ImioRevisionHistoryAdapter).The@@historyviewThe@@historyviewwill display the histories as a table with each information in a column : action, author, date/time, comments.You define in thehistories_to_handleattribute of the view, what histories (named adapters) it should display.Every histories are sorted together on thetimekey as it uses the same structure.TranslationsThis product has been translated intoFrench.Spanish.You can contribute for any message missing or other new languages, join us atPloneGov iMiO TeamintoTransifex.netservice with all world Plone translators community.ContributorsChangelog1.33 (2023-12-11)Addedutils.add_event_to_wf_historyto insert an event
to theworkflow_historyof an element.
[gbastien]1.32 (2023-11-27)InIHDocumentBylineViewlet, do not display creator ifshow_historyisFalseas creator is part of the history.
[gbastien]In@@historyview, display a@@headerview underHistorytitle that will
by default display theprettylinkof the context, useful when displaying
history in a popup from a dashboard containing plenty of elements.
Added direct dependency onimio.prettylink.
[gbastien]1.31 (2023-10-27)Added parameterignore_previous_event_actions=[]toutils.getLastAction,
this way when finding the last action in a history, it will check previous
event action and continue if it is an action to ignore.
[gbastien]1.30 (2023-09-21)Addedutils.get_event_by_timethat will return an history event based
on a given float event time.
[gbastien]Formalized use ofEventPreviewView.may_view_historized_data.
[gbastien]1.29 (2023-06-27)MakeIHContentHistoryView.renderCommentsmore robust by passing originalmimetype=’text/plain’to avoidportal_transformsdetecting it automatically
that can lead to wrong detection.
[gbastien]1.28 (2023-02-27)Added possibility to display an event preview under the comment
in the@@contenthistoryview.
[gbastien]Make thehighlight_last_commentfunctionnality generic, it was only used
with WF history but now any history may be sethighlight_last_comment=True.
[gbastien]1.27 (2022-06-14)Addedsafe_utils.pythat will only include safe utils.
[gbastien]1.26 (2022-03-08)Fixed display of actor fullname in@@historyview.
[gbastien]1.25 (2022-03-07)Optimized@@contenthistoryview.
[gbastien]1.24 (2022-02-25)Incontent_historytemplate, only fix date column width,
for other columns, let the browser optimize it.
[gbastien]1.23 (2021-04-21)Add Transifex.net service integration to manage the translation process.
[macagua]Add Spanish translation
[macagua]1.22 (2021-03-04)Changed default toFalsefor parameterscheckMayViewEvent=FalseandcheckMayViewComment=Falseofutils.getLastAction, this way, we get last
action even if current user may not, and it is quicker.
This fix a performance issue inImioWfHistoryAdapter.historyLastEventHasCommentswhen called several times.
[gbastien]Inutils.getLastAction, parameteractionmay bebefore_lastand will
return the before last action if it exists.
[gbastien]1.21 (2020-10-26)Added helperutils.get_all_history_attrto get every occurence of a givenattr_namein ahistory. This will return everyreview_statefrom theworkflowhistory for example.
[gbastien]1.20 (2020-10-01)Added parameterscheckMayViewEvent=FalseandcheckMayViewComment=Falsetoutils.getLastWFAction, this way, we get last WF action even if current user
may not, and it is quicker.
[gbastien]1.19 (2019-10-01)Allow access to moduleutilsfrom restricted python (TAL expression).
[gbastien]1.18 (2019-01-11)AsImioWfHistoryAdapter.ignorableHistoryCommentsshould return a list of
unicode, we force unicode comparison inImioWfHistoryAdapter.historyLastEventHasComments, this way we avoid warning
in Zope log.
[gbastien]isorton imports.
[gbastien]Added helperutils.getLastWFActionthat is actually a shortcut toutils.getLastActionusing theIImioHistory‘workflow’ adapter.
[gbastien]1.17 (2018-03-19)Factorizeshow_historyfunctionnality.  The method is now defined on theIHContentHistoryViewand is used byIHDocumentBylineViewlet.show_historyand the@@historyview.
This way, we make sure that if the link is not shown on the viewlet, the
history is not shown in the@@historyviewif user enter the view name
manually in the browser.
[gbastien]1.16 (2018-02-22)Use@memoizeonBaseImioHistoryAdapter.get_history_dataandBaseImioHistoryAdapter.getHistoryto avoid recomputing it if adapter did
not changed.  This is useful for thehighlight_history_linkfunctionnality.
[gbastien]utils.getLastActionnow receives anIImioHistoryadapter as first
argument instead an obj and an adapter name.
[gbastien]1.15 (2018-02-09)Added attributeImioWfHistoryAdapter.include_previous_review_state,Falseby default, if set toTrue, the returned history will includeprevious_review_state.
[gbastien]1.14 (2018-01-23)Refactored code so it is easy to handle no histories.
[gbastien]Do not fail to call workflow_history specific methods if obj has no workflow.
[gbastien]IHContentHistoryView.renderCommentsnow receives the entire event as
parameter not just the comment so it pass the different values of the event as
mapping to the translate method so it is useable in translated comment.
[gbastien]AddedIHContentHistoryView.renderCustomJSto be able to inject custom JS
when loading the@@historyview, especially because it is loaded as an
overlay.
[gbastien]Added helperutils.add_event_to_historythat adds an event to an history
respecting minimum required data.
[gbastien]Added theBaseImioHistoryAdapter.mayViewEventmethod used when parametercheckMayViewEvent=True, it returnsTrueby default but is made to be
overrided, if returns False, the entire event is not displayed in the@@historyview.
[gbastien]1.13 (2017-12-07)Inutils.getLastAction, do not break if history is empty, added tests.
[gbastien]1.12 (2017-11-30)Define aBaseImioHistoryAdapterto base new history adapter on.checkMayView=Trueis now a default parameter ofgetHistory.
[gbastien]For now, specifically restrict histories displayed in the@@historyviewtoworkflowandrevision.
[gbastien]Added methodutils.getLastActionthat returns the metadata of last action of
a given name for a given history.
[gbastien]1.11 (2017-06-23)Adapted History word highlighting ti display it bigger and underline it so
it is even more viewable.
[gbastien]1.10 (2017-06-14)In ImioWfHistoryAdapter.historyLastEventHasComments, call
ImioWfHistoryAdapter.getHistory with parameter ‘for_last_event=True’ so
getHistory knows that it queries only relevant last event and when overrided,
the package overriding it may avoid heavy processing if relevant.
[gbastien]Get rid of unittest2.
[gbastien]1.9 (2016-10-12)Do not break in IHContentHistoryView.getTransitionTitle if transitionName
contains special characters.
[gbastien]1.8 (2015-10-06)Make sure comments is displayed correctly by using portal_transforms to
turn it to ‘text/html’ before displaying it in the PageTemplate using
‘structure’.
[gbastien]1.7 (2015-09-28)Remove revision columns when unused.
[DieKatze]In ImioRevisionHistoryAdapter.getHistory, take into account the
‘checkMayView’ parameter by implementing a ‘mayViewRevision’ method so it
is possible to restrict access to a specific revision if necessary
[gbastien]1.6 (2015-09-10)Added @@history-version-preview view that is called by default in the
content_history but that renders nothing.  It is made to be registered for a
relevant content_type so it is possible to display a preview of a versioned
object directly in the history popup
[gbastien]1.5 (2015-07-14)Add revision history management.
[cedricmessiant]1.4 (2015-04-15)Added helper method ‘utils.getPreviousEvent’ that will receive an event
as parameter and will return the previous event in the workflow_history
if found
[gbastien]1.3 (2015-04-15)Do not reverse workflow_history in ImioHistoryAdapter.getHistory
as it is for display purpose, do this in the IHContentHistoryView.getHistory
[gbastien]Added parameter ‘checkMayView’ to ImioHistoryAdapter.getHistory to be able
to enable/disable mayViewComment check while getting the workflow_history
[gbastien]1.2 (2015-04-01)Be defensive in getHistory, do not fail if no workflow used or
if element has no workflow_history attribute
[gbastien]1.1 (2015-03-31)Register translations
[gbastien]1.0 (2015-03-30)Intial release