diff options
| author | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-08-25 21:34:55 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-08-25 21:34:55 +0200 | 
| commit | 3baf86f27dcebc7a968c01bee6cd2c1b3fb9a8a2 (patch) | |
| tree | 231ca1cfc63c661930644922975200edf0273785 /archaeological_operations/models.py | |
| parent | a698072bb49a58e376aeef138260d3df197a3f64 (diff) | |
| download | Ishtar-3baf86f27dcebc7a968c01bee6cd2c1b3fb9a8a2.tar.bz2 Ishtar-3baf86f27dcebc7a968c01bee6cd2c1b3fb9a8a2.zip | |
Change saved filename (refs #244)
Diffstat (limited to 'archaeological_operations/models.py')
| -rw-r--r-- | archaeological_operations/models.py | 32 | 
1 files changed, 26 insertions, 6 deletions
| diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 9e2fc9b4c..83f4f47c6 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -148,18 +148,38 @@ class Operation(BaseHistorizedItem, OwnPerms):          self.save()          return self.cached_label +    @property +    def short_class_name(self): +        return _(u"OPE") + +    @property +    def reference(self): +        if self.code_patriarche: +            return unicode(self.code_patriarche) +        if self.year and self.operation_code: +            return u"-".join((unicode(self.year), +                              unicode(self.operation_code))) +        return "00" +      def _generate_cached_label(self): -        items = [unicode(_('Intercommunal'))] -        if self.towns.count() == 1: -            items[0] = unicode(self.towns.all()[0]) -        if self.operation_code: -            items.append("-".join((unicode(self.year), -                               unicode(self.operation_code)))) +        items = [self.get_town_label(), self.reference]          if self.common_name:              items.append(self.common_name)          cached_label = settings.JOINT.join(items)          return cached_label +    def get_town_label(self): +        lbl = unicode(_('Intercommunal')) +        if self.towns.count() == 1: +            lbl = self.towns.all()[0].name +        return lbl + +    def get_department(self): +        q = self.towns +        if not self.towns.count(): +            return '00' +        return self.towns.all()[0].numero_insee[:2] +      def grouped_parcels(self):          return Parcel.grouped_parcels(list(self.parcels.all())) | 
