summaryrefslogtreecommitdiff
path: root/ishtar_common/models_rest.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/models_rest.py')
-rw-r--r--ishtar_common/models_rest.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/ishtar_common/models_rest.py b/ishtar_common/models_rest.py
index e16d37a90..18f6c4c3f 100644
--- a/ishtar_common/models_rest.py
+++ b/ishtar_common/models_rest.py
@@ -17,6 +17,10 @@ try:
except (AssertionError, ImportError):
UnoCalc = None
+from django.apps import apps
+from django.template import loader
+
+from ishtar_common.models_common import SheetFilter
from ishtar_common.utils import ugettext_lazy as _
@@ -38,8 +42,6 @@ MAIN_MODELS = dict(
)
-
-
class ApiUser(models.Model):
user_ptr = models.OneToOneField(
User, primary_key=True, related_name="apiuser", on_delete=models.CASCADE
@@ -68,9 +70,13 @@ class ApiSearchModel(models.Model):
verbose_name = _("API - Remote access - Search model")
verbose_name_plural = _("API - Remote access - Search models")
+ def __str__(self):
+ return f"{self.user} - {self.content_type}"
+
-class ApiSheetFilter(models.Model):
- api_search_model = models.ForeignKey(ApiSearchModel, on_delete=models.CASCADE)
+class ApiSheetFilter(SheetFilter):
+ api_search_model = models.ForeignKey(ApiSearchModel, on_delete=models.CASCADE,
+ related_name="sheet_filters")
class Meta:
verbose_name = _("API - Remote access - Sheet filter")
@@ -78,7 +84,9 @@ class ApiSheetFilter(models.Model):
def get_template(self):
ct = self.api_search_model.content_type
- return f"{ct.app_label}/templatestemplates/ishtar/sheet_{ct.model}.html"
+ model = apps.get_model(ct.app_label, ct.model)
+ tpl = loader.get_template(f"ishtar/sheet_{model.SLUG}.html")
+ return tpl.template.origin.name
class ApiExternalSource(models.Model):