diff options
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r-- | archaeological_operations/models.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index a4a225ff0..0823118e0 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -271,14 +271,22 @@ class Operation(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem, def show_url(self): return reverse('show-operation', args=[self.pk, '']) - @property - def reference(self): + def get_reference(self, full=False): + ref = "" if self.code_patriarche: - return unicode(self.code_patriarche) + ref = unicode(self.code_patriarche) + if not full: + return ref if self.year and self.operation_code: - return u"-".join((unicode(self.year), + if ref: + ref += u" - " + ref += u"-".join((unicode(self.year), unicode(self.operation_code))) - return "00" + return ref or "00" + + @property + def reference(self): + return self.get_reference() @property def report_delivery_delay(self): @@ -289,7 +297,7 @@ class Operation(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem, def _generate_cached_label(self): - items = [self.get_town_label(), self.reference] + items = [self.get_town_label(), self.get_reference(full=True)] if self.common_name: items.append(self.common_name) cached_label = settings.JOINT.join(items) |