diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-05-05 15:29:11 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-05-05 15:29:11 +0200 |
commit | 91c17204227625501f1d2b26adad46872f45a30e (patch) | |
tree | 9cffffc070d4cc50609ecb40bc59915a8ebc0b32 | |
parent | a68bedba648cd3457c536e83d7f327d92474dfc9 (diff) | |
download | Ishtar-91c17204227625501f1d2b26adad46872f45a30e.tar.bz2 Ishtar-91c17204227625501f1d2b26adad46872f45a30e.zip |
Container: manage general index
-rw-r--r-- | archaeological_warehouse/models.py | 12 | ||||
-rw-r--r-- | example_project/settings.py | 11 | ||||
-rw-r--r-- | ishtar_common/models_imports.py | 10 |
3 files changed, 22 insertions, 11 deletions
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index 63d4497ac..7b98a385a 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -20,6 +20,7 @@ import datetime import uuid +from django.conf import settings from django.contrib.gis.db import models from django.contrib.postgres.indexes import GinIndex from django.core.urlresolvers import reverse @@ -898,7 +899,16 @@ class Container(DocumentItem, LightHistorizedItem, QRCodeItem, GeoItem, return actions def pre_save(self): - if not self.index and self.responsible_id: + if self.index: + return + if settings.ISHTAR_CONTAINER_INDEX == "general": + q = Container.objects + if q.count(): + self.index = int( + q.aggregate(Max("index"))["index__max"] or 0) + 1 + else: + self.index = 1 + elif self.responsible_id: # default is index by warehouse q = Container.objects.filter(responsible=self.responsible) if q.count(): self.index = int(q.aggregate(Max("index"))["index__max"]) + 1 diff --git a/example_project/settings.py b/example_project/settings.py index ae795d04a..44e703104 100644 --- a/example_project/settings.py +++ b/example_project/settings.py @@ -255,8 +255,6 @@ ISHTAR_QRCODE_VERSION = 6 # density of the QR code ISHTAR_QRCODE_SCALE = 2 # scale of the QR code ISHTAR_DEFAULT_YEAR = 1900 -ISHTAR_FILE_PREFIX = "" - SRID = 4326 # WGS84 - World SURFACE_SRID = 4326 # WGS84 - World ENCODING = 'windows-1252' @@ -269,9 +267,9 @@ JOINT = u" | " # not managed cautiously the dir contening theses scripts is not set by default ISHTAR_SCRIPT_DIR = "" -ISHTAR_FILE_PREFIX = u"" -ISHTAR_OPE_PREFIX = u"OA" -ISHTAR_DEF_OPE_PREFIX = u"OP" +ISHTAR_FILE_PREFIX = "" +ISHTAR_OPE_PREFIX = "OA" +ISHTAR_DEF_OPE_PREFIX = "OP" # string len of find indexes - i.e: find with index 42 will be 00042 ISHTAR_FINDS_INDEX_ZERO_LEN = 5 ISHTAR_OPE_COL_FORMAT = None @@ -286,6 +284,9 @@ ISHTAR_SEARCH_LANGUAGE = "french" ISHTAR_SECURE = True +# index by warehouse or on the whole database +ISHTAR_CONTAINER_INDEX = 'warehouse' # or "general" + ISHTAR_DPTS = [] MAX_ATTEMPTS = 1 # django background tasks diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index b4b41787b..b4749fc2c 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -482,14 +482,14 @@ class NamedManager(models.Manager): class Regexp(models.Model): - name = models.CharField(_(u"Name"), max_length=100, unique=True) - description = models.TextField(_(u"Description"), blank=True, null=True) - regexp = models.CharField(_(u"Regular expression"), max_length=500) + name = models.CharField(_("Name"), max_length=100, unique=True) + description = models.TextField(_("Description"), blank=True, null=True) + regexp = models.CharField(_("Regular expression"), max_length=500) objects = NamedManager() class Meta: - verbose_name = _(u"Importer - Regular expression") - verbose_name_plural = _(u"Importer - Regular expressions") + verbose_name = _("Importer - Regular expression") + verbose_name_plural = _("Importer - Regular expressions") def __str__(self): return self.name |