diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-02-02 18:48:32 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-02-28 12:15:24 +0100 |
commit | 265648d0a8232499d3468c198d4371833363d298 (patch) | |
tree | 02a2ba40cad1698f8f3b7a1243492f69822b0c90 /archaeological_warehouse/models.py | |
parent | 77cbfe3a5c67c5a844e87078eb4f0afb84770a97 (diff) | |
download | Ishtar-265648d0a8232499d3468c198d4371833363d298.tar.bz2 Ishtar-265648d0a8232499d3468c198d4371833363d298.zip |
No index for stationary containers
Diffstat (limited to 'archaeological_warehouse/models.py')
-rw-r--r-- | archaeological_warehouse/models.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index 77ae3c6d1..d80559acc 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -870,7 +870,7 @@ class Container(DocumentItem, Merge, LightHistorizedItem, parent = models.ForeignKey("Container", verbose_name=_("Parent container"), on_delete=models.SET_NULL, related_name="children", blank=True, null=True) - index = models.IntegerField(_("Container ID"), default=0) + index = models.IntegerField(_("Container ID"), blank=True, null=True) old_reference = models.TextField(_("Old reference"), blank=True, default="") external_id = models.TextField(_("External ID"), blank=True, default="") auto_external_id = models.BooleanField( @@ -891,8 +891,7 @@ class Container(DocumentItem, Merge, LightHistorizedItem, verbose_name = _("Container") verbose_name_plural = _("Containers") ordering = ('cached_label',) - unique_together = [('index', 'location'), - ('location', 'container_type', 'parent', + unique_together = [('location', 'container_type', 'parent', 'reference')] permissions = ( ("view_container", "Can view all Containers"), @@ -972,6 +971,8 @@ class Container(DocumentItem, Merge, LightHistorizedItem, return self.precise_location def _generate_cached_location(self): + if not self.index: + return self.location.name items = [self.location.name, str(self.index)] cached_label = " - ".join(items) return cached_label @@ -1365,6 +1366,8 @@ class Container(DocumentItem, Merge, LightHistorizedItem, self.collection_id = self.location_id else: self.collection = self.location + if self.container_type.stationary: + return q = Container.objects.filter(index=self.index, location=self.location) if self.id: q = q.exclude(id=self.id) @@ -1405,7 +1408,7 @@ class Container(DocumentItem, Merge, LightHistorizedItem, self._update_warehouse_max_division() updated = False - if not self.index: + if not self.index and not self.container_type.stationary: self.skip_history_when_saving = True q = Container.objects.filter(responsible=self.responsible).exclude( pk=self.pk).order_by('-index') |