From f7b7ba41beb4928e8c7dda129f8c92e5965416d8 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 23 Dec 2016 19:12:03 +0100 Subject: Change container filename (refs #3390) --- archaeological_warehouse/models.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'archaeological_warehouse/models.py') 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) -- cgit v1.2.3