diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-01-11 19:23:51 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-01-11 19:23:51 +0100 |
commit | 6275ac4d3388f912a831c3f6178c3832ce9297b5 (patch) | |
tree | f5d133b3456888ccd805fdf5c50b880acab3e502 /ishtar_common/utils.py | |
parent | d68eed24e409cf6b5c15c77fbf1034843eea9acd (diff) | |
download | Ishtar-6275ac4d3388f912a831c3f6178c3832ce9297b5.tar.bz2 Ishtar-6275ac4d3388f912a831c3f6178c3832ce9297b5.zip |
Use JSON for M2M history
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r-- | ishtar_common/utils.py | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 56c6f669f..e293562ff 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -931,26 +931,22 @@ def get_urls_for_model(model, views, own=False, autocomplete=False, return urls -HISTORY_M2M_SPLIT = u"*||*" - - def m2m_historization_changed(sender, **kwargs): obj = kwargs.get('instance', None) if not obj: return - hist_values = {} + hist_values = obj.history_m2m or {} for attr in obj.HISTORICAL_M2M: values = [] for value in getattr(obj, attr).all(): if not hasattr(value, "history_compress"): continue values.append(value.history_compress()) - hist_values['historical_' + attr] = HISTORY_M2M_SPLIT.join(values) - for key in hist_values: - setattr(obj, key, hist_values[key]) + hist_values[attr] = values # force resave of last history record if hasattr(obj, 'skip_history_when_saving'): delattr(obj, 'skip_history_when_saving') + obj.history_m2m = hist_values obj._force_history = True q = obj.history.order_by("-history_date") if q.count(): |