summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
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
commit38302f3a894c04df8e3ab5bd24d9c8326a8c4d53 (patch)
tree231ca1cfc63c661930644922975200edf0273785 /archaeological_operations/models.py
parent7d35c4a7672007f966bd47ff602e3e818dd2e042 (diff)
downloadIshtar-38302f3a894c04df8e3ab5bd24d9c8326a8c4d53.tar.bz2
Ishtar-38302f3a894c04df8e3ab5bd24d9c8326a8c4d53.zip
Change saved filename (refs #244)
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r--archaeological_operations/models.py32
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()))