summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-12-23 18:54:42 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-12-23 18:54:42 +0100
commitfd1c59b614a3f1101dde3a0cdb15c9ef686f73af (patch)
tree2c764448d53fd4d0036b061cabdf730b1960d66e
parentcd421572fcfb1ffc09fc9f7c6c5e4b90182e027f (diff)
downloadIshtar-fd1c59b614a3f1101dde3a0cdb15c9ef686f73af.tar.bz2
Ishtar-fd1c59b614a3f1101dde3a0cdb15c9ef686f73af.zip
Fix cached label generation for containers
-rw-r--r--archaeological_warehouse/forms.py2
-rw-r--r--archaeological_warehouse/models.py13
2 files changed, 10 insertions, 5 deletions
diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py
index cc21f65f6..d51dcf1f4 100644
--- a/archaeological_warehouse/forms.py
+++ b/archaeological_warehouse/forms.py
@@ -183,7 +183,7 @@ class ContainerModifyForm(ContainerForm):
self.fields.keyOrder.pop(self.fields.keyOrder.index('index'))
self.fields.keyOrder.insert(
self.fields.keyOrder.index("location") + 1, 'index')
- )
+
class ContainerSelect(TableSelect):
location = get_warehouse_field()
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py
index d272a833a..698c475f8 100644
--- a/archaeological_warehouse/models.py
+++ b/archaeological_warehouse/models.py
@@ -135,7 +135,8 @@ post_delete.connect(post_save_cache, sender=ContainerType)
class Container(LightHistorizedItem):
- TABLE_COLS = ['reference', 'container_type__label', 'location__name']
+ TABLE_COLS = ['reference', 'container_type__label', 'cached_location',
+ 'precise_location']
# search parameters
EXTRA_REQUEST_KEYS = {
@@ -144,6 +145,10 @@ class Container(LightHistorizedItem):
'reference': 'reference__icontains',
}
SHOW_URL = 'show-container'
+ COL_LABELS = {
+ 'cached_location': _(u"Location - index"),
+ 'precise_location': _(u"Precise localisation"),
+ }
CACHED_LABELS = ['cached_label', 'cached_location']
# fields
@@ -176,7 +181,7 @@ class Container(LightHistorizedItem):
return cached_label
def _generate_cached_location(self):
- items = [self.location, self.index]
+ items = [self.location.name, unicode(self.index)]
cached_label = u" - ".join(items)
return cached_label
@@ -189,7 +194,7 @@ class Container(LightHistorizedItem):
@property
def precise_location(self):
- location = unicode(self.location)
+ location = self.location.name
locas = [
u"{} {}".format(loca.division.division, loca.reference)
for loca in ContainerLocalisation.objects.filter(
@@ -233,4 +238,4 @@ class ContainerLocalisation(models.Model):
def save(self, *args, **kwargs):
super(ContainerLocalisation, self).save(*args, **kwargs)
- cached_label_changed(Container, {'instance': self.container})
+ cached_label_changed(Container, instance=self.container)