diff options
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())) |