From 11a0a14931cc5cc6f6f2a128f6d02dea93562438 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 5 Feb 2018 12:18:10 +0100 Subject: History: if a previous step do not exist, get the first in history --- ishtar_common/models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 610d92551..674e42538 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1179,8 +1179,11 @@ class BaseHistorizedItem(FullSearch, Imported, JsonData, FixAssociated): historized = self.history.all() item = None if step: - assert len(historized) > step - item = historized[step] + if len(historized) <= step: + # silently return the last step if too far in the history + item = historized[len(historized) - 1] + else: + item = historized[step] else: for step, item in enumerate(historized): if item.history_date == date: -- cgit v1.2.3