diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-02-05 12:18:10 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-02-05 12:18:10 +0100 | 
| commit | 5cd6aeba3e94c89f6ed13bd0ff5f02a9b8fbdf18 (patch) | |
| tree | 93bff58404c855b89d4c337ce1f01c34bacacd41 | |
| parent | 4166727f2f45089794d420101f45710d2a251f1d (diff) | |
| download | Ishtar-5cd6aeba3e94c89f6ed13bd0ff5f02a9b8fbdf18.tar.bz2 Ishtar-5cd6aeba3e94c89f6ed13bd0ff5f02a9b8fbdf18.zip | |
History: if a previous step do not exist, get the first in history
| -rw-r--r-- | ishtar_common/models.py | 7 | 
1 files 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: | 
