summaryrefslogtreecommitdiff
path: root/archaeological_warehouse/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-12-23 19:12:03 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-12-23 19:12:03 +0100
commitf7b7ba41beb4928e8c7dda129f8c92e5965416d8 (patch)
treec210e47cd41aac3a4b57b8f1cfebc665ca8055eb /archaeological_warehouse/models.py
parentfd1c59b614a3f1101dde3a0cdb15c9ef686f73af (diff)
downloadIshtar-f7b7ba41beb4928e8c7dda129f8c92e5965416d8.tar.bz2
Ishtar-f7b7ba41beb4928e8c7dda129f8c92e5965416d8.zip
Change container filename (refs #3390)
Diffstat (limited to 'archaeological_warehouse/models.py')
-rw-r--r--archaeological_warehouse/models.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py
index 698c475f8..a101bf083 100644
--- a/archaeological_warehouse/models.py
+++ b/archaeological_warehouse/models.py
@@ -136,7 +136,7 @@ post_delete.connect(post_save_cache, sender=ContainerType)
class Container(LightHistorizedItem):
TABLE_COLS = ['reference', 'container_type__label', 'cached_location',
- 'precise_location']
+ 'divisions_lbl']
# search parameters
EXTRA_REQUEST_KEYS = {
@@ -147,7 +147,7 @@ class Container(LightHistorizedItem):
SHOW_URL = 'show-container'
COL_LABELS = {
'cached_location': _(u"Location - index"),
- 'precise_location': _(u"Precise localisation"),
+ 'divisions_lbl': _(u"Precise localisation"),
}
CACHED_LABELS = ['cached_label', 'cached_location']
@@ -187,20 +187,25 @@ class Container(LightHistorizedItem):
@property
def associated_filename(self):
- return datetime.date.today().strftime('%Y-%m-%d') + '-' + \
- "-".join([str(slugify(getattr(self, attr)))
- for attr in ('location', 'container_type',
- 'reference')])
+ filename = datetime.date.today().strftime('%Y-%m-%d')
+ filename += u'-' + self.reference
+ filename += u"-" + self.location.name
+ filename += u"-" + unicode(self.index)
+ filename += u"-" + self.divisions_lbl
+ return slugify(filename)
@property
def precise_location(self):
- location = self.location.name
+ return self.location.name + u" - " + self.divisions_lbl
+
+ @property
+ def divisions_lbl(self):
locas = [
u"{} {}".format(loca.division.division, loca.reference)
for loca in ContainerLocalisation.objects.filter(
- container=self)
- ]
- return location + u" | " + u", ".join(locas)
+ container=self)
+ ]
+ return u" | ".join(locas)
def save(self, *args, **kwargs):
super(Container, self).save(*args, **kwargs)