Skip to content

Commit d50b660

Browse files
authored
Merge pull request #890 from derickdiaz/bug-date-update-field-not-updated-after-asset-update
[BUG] date_update updated on object update
2 parents 4d21d9f + 6f7c6e2 commit d50b660

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

source/app/util.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,31 @@ def _do_cleanup(self, wr):
4747

4848

4949
def add_obj_history_entry(obj, action, commit=False):
50-
if hasattr(obj, 'modification_history'):
50+
date_update = datetime.datetime.now(datetime.timezone.utc)
51+
timestamp = date_update.timestamp()
52+
utc = date_update
5153

54+
if hasattr(obj, 'modification_history'):
5255
if isinstance(obj.modification_history, dict):
53-
5456
obj.modification_history.update({
55-
datetime.datetime.now().timestamp(): {
57+
timestamp: {
5658
'user': iris_current_user.user,
5759
'user_id': iris_current_user.id,
5860
'action': action
5961
}
6062
})
61-
6263
else:
63-
6464
obj.modification_history = {
65-
datetime.datetime.now().timestamp(): {
65+
timestamp: {
6666
'user': iris_current_user.user,
6767
'user_id': iris_current_user.id,
6868
'action': action
6969
}
7070
}
71+
72+
if hasattr(obj, 'date_update'):
73+
obj.date_update = utc
74+
7175
flag_modified(obj, "modification_history")
7276
if commit:
7377
db.session.commit()

0 commit comments

Comments
 (0)