diff options
| 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 | 
| commit | fcf05ca0f1fe9c70781eda0e46df084190e10783 (patch) | |
| tree | c210e47cd41aac3a4b57b8f1cfebc665ca8055eb | |
| parent | 33222b95fd40d91a26f94196c1ed9b95ae770eb7 (diff) | |
| download | Ishtar-fcf05ca0f1fe9c70781eda0e46df084190e10783.tar.bz2 Ishtar-fcf05ca0f1fe9c70781eda0e46df084190e10783.zip  | |
Change container filename (refs #3390)
| -rw-r--r-- | archaeological_warehouse/models.py | 25 | 
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)  | 
