From 54b86803f7a9e2c1013669d72212238cd74debe7 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 26 Aug 2013 20:07:49 +0200 Subject: Shorten the label of files in operation list (refs #408) --- archaeological_files/models.py | 4 ++++ archaeological_operations/models.py | 10 +++++++++- ishtar_common/views.py | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/archaeological_files/models.py b/archaeological_files/models.py index a6900ec08..7b7a7d9b5 100644 --- a/archaeological_files/models.py +++ b/archaeological_files/models.py @@ -142,6 +142,10 @@ class File(BaseHistorizedItem, OwnPerms): self.save() return self.cached_label + @property + def short_label(self): + return settings.JOINT.join(unicode(self).split(settings.JOINT)[1:]) + @property def reference(self): return u"-".join((unicode(self.year), diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 83f4f47c6..589d8d69e 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -73,7 +73,8 @@ class Period(GeneralType) : class Operation(BaseHistorizedItem, OwnPerms): TABLE_COLS = ['year_index', 'operation_type', 'remains', 'towns', - 'associated_file', 'start_date', 'excavation_end_date'] + 'associated_file_short_label', 'start_date', + 'excavation_end_date'] start_date = models.DateField(_(u"Start date"), null=True, blank=True) excavation_end_date = models.DateField(_(u"Excavation end date"), null=True, blank=True) @@ -183,6 +184,13 @@ class Operation(BaseHistorizedItem, OwnPerms): def grouped_parcels(self): return Parcel.grouped_parcels(list(self.parcels.all())) + associated_file_short_label_lbl = _(u"Archaelogical file") + @property + def associated_file_short_label(self): + if not self.associated_file: + return "" + return self.associated_file.short_label + @classmethod def get_available_operation_code(cls, year=None): if not year: diff --git a/ishtar_common/views.py b/ishtar_common/views.py index dc72b8d12..554fcc839 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -338,7 +338,7 @@ def get_item(model, func_name, default_name, extra_request_keys=[], "records":items_nb, "rows":rows, "page":page_nb, - "total":items_nb/row_nb + 1, + "total":(items_nb/row_nb + 1) if row_nb else items_nb, }) return HttpResponse(data, mimetype='text/plain') elif data_type == "csv": -- cgit v1.2.3