diff options
Diffstat (limited to 'archaeological_warehouse')
| -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) | 
