summaryrefslogtreecommitdiff
path: root/archaeological_warehouse/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2020-04-07 12:36:55 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-28 12:15:20 +0100
commit55194aeec747fc07dcaf054877dd194fd1106039 (patch)
treecc2d30385aebb2a7b6d3aebf8dbaa26134617bf0 /archaeological_warehouse/models.py
parent33bcdb096df9e56238f6e21ad0c1da7bcd8e87c9 (diff)
downloadIshtar-55194aeec747fc07dcaf054877dd194fd1106039.tar.bz2
Ishtar-55194aeec747fc07dcaf054877dd194fd1106039.zip
New container management: change ext id
Diffstat (limited to 'archaeological_warehouse/models.py')
-rw-r--r--archaeological_warehouse/models.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py
index c4b26e3d1..c9e0ad4aa 100644
--- a/archaeological_warehouse/models.py
+++ b/archaeological_warehouse/models.py
@@ -724,10 +724,12 @@ class Container(DocumentItem, LightHistorizedItem, QRCodeItem, GeoItem,
DISABLE_POLYGONS = False
class Meta:
- verbose_name = _(u"Container")
- verbose_name_plural = _(u"Containers")
+ verbose_name = _("Container")
+ verbose_name_plural = _("Containers")
ordering = ('cached_label',)
- unique_together = ('index', 'responsible')
+ unique_together = [('index', 'responsible'),
+ ('location', 'container_type', 'parent',
+ 'reference')]
permissions = (
("view_container", u"Can view all Containers"),
("view_own_container", u"Can view own Container"),
@@ -746,6 +748,12 @@ class Container(DocumentItem, LightHistorizedItem, QRCodeItem, GeoItem,
def short_label(self):
return "{} {}".format(self.container_type.label, self.reference)
+ @property
+ def parent_external_id(self):
+ if not self.parent:
+ return self.location.external_id
+ return self.parent.external_id
+
def natural_key(self):
return (self.uuid, )
@@ -843,7 +851,7 @@ class Container(DocumentItem, LightHistorizedItem, QRCodeItem, GeoItem,
def get_localisation(self, place):
locas = self.get_localisations()
- if len(locas) < (place + 1):
+ if len(list(locas)) < (place + 1):
return ""
return locas[place]