summaryrefslogtreecommitdiff
path: root/ishtar_common/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2021-12-15 18:23:02 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-12 12:20:59 +0100
commit55994e46b462bdec0540f785468b8cf4ee242364 (patch)
treef512598dd83ecfdcb5eac2a830946edd8d1c2b42 /ishtar_common/models.py
parent271e24ea891b0946f7e65cfeb3d4612599762d6d (diff)
downloadIshtar-55994e46b462bdec0540f785468b8cf4ee242364.tar.bz2
Ishtar-55994e46b462bdec0540f785468b8cf4ee242364.zip
Syndication - filter field on sheet
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r--ishtar_common/models.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index c1a53213f..1f0fd6095 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -113,10 +113,7 @@ from ishtar_common.models_imports import (
TargetKeyGroup,
ValueFormater,
)
-from ishtar_common.models_rest import (
- ApiUser,
- ApiSearchModel
-)
+from ishtar_common.models_rest import ApiUser, ApiSearchModel
from ishtar_common.utils import (
get_cache,
@@ -354,7 +351,7 @@ class HistoryModel(models.Model):
if not models.endswith(".models"):
models += ".models"
models = import_module(models)
- model = getattr(models, self.__class__.__name__[len("Historical"):])
+ model = getattr(models, self.__class__.__name__[len("Historical") :])
field = getattr(model, key)
if hasattr(field, "rel"):
field = field.rel
@@ -1724,6 +1721,24 @@ class CustomFormJsonField(models.Model):
)
+class SheetFilter(models.Model):
+ key = models.CharField(_("Key"), max_length=200)
+
+ class Meta:
+ abstract = True
+
+ def get_template(self):
+ raise NotImplemented()
+
+ def get_keys(self):
+ tpl = os.path.abspath(
+ os.path.join(settings.ROOT_PATH, "..", self.get_template())
+ )
+ r = re.compile("item\.([_a-zA-Z])+")
+ with open(tpl, "r") as fle:
+ return list(set(r.findall(fle.read())))
+
+
class GlobalVar(models.Model, Cached):
slug = models.SlugField(_("Variable name"), unique=True)
description = models.TextField(
@@ -3658,7 +3673,7 @@ class Document(
COL_LABELS = {
"authors__cached_label": _("Authors"),
"complete_identifier": _("Identifier"),
- "source_type__label": _("Type")
+ "source_type__label": _("Type"),
}
CACHED_LABELS = ["cache_related_label"]