summaryrefslogtreecommitdiff
path: root/ishtar_common/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r--ishtar_common/models.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index e1318ef62..2915c4997 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -69,7 +69,7 @@ from ishtar_common.models_imports import ImporterModel, ImporterType, \
Import, TargetKeyGroup
from ishtar_common.utils import get_cache, disable_for_loaddata, create_slug, \
get_all_field_names, merge_tsvectors, cached_label_changed, \
- generate_relation_graph
+ generate_relation_graph, HISTORY_M2M_SPLIT
__all__ = [
'ImporterModel', 'ImporterType', 'ImporterDefault', 'ImporterDefaultValues',
@@ -507,6 +507,21 @@ class GeneralType(Cached, models.Model):
def natural_key(self):
return (self.txt_idx,)
+ def history_compress(self):
+ return self.txt_idx
+
+ @classmethod
+ def history_decompress(cls, value=""):
+ if not value:
+ value = ""
+ res = []
+ for txt_idx in value.split(HISTORY_M2M_SPLIT):
+ try:
+ res.append(cls.objects.get(txt_idx=txt_idx))
+ except cls.DoesNotExist:
+ continue
+ return res
+
@property
def explicit_label(self):
return u"{} ({})".format(self.label, self._meta.verbose_name)
@@ -1433,6 +1448,8 @@ class BaseHistorizedItem(DocumentItem, FullSearch, Imported, JsonData,
IS_BASKET = False
EXTERNAL_ID_KEY = ''
EXTERNAL_ID_DEPENDENCIES = []
+ HISTORICAL_M2M = []
+
history_modifier = models.ForeignKey(
User, related_name='+', on_delete=models.SET_NULL,
verbose_name=_(u"Last editor"), blank=True, null=True)