summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@peacefrogs.net>2013-08-26 20:07:49 +0200
committerÉtienne Loks <etienne.loks@peacefrogs.net>2013-08-26 20:07:49 +0200
commitcc0f377471c838076b8f28f113ba8ddf6ba4740f (patch)
tree811c188df7e29a2f7cc0f622aec9cc86713549df
parente1d47df4a1f5a3c1106f70b1e509c877f8e6ebd8 (diff)
downloadIshtar-cc0f377471c838076b8f28f113ba8ddf6ba4740f.tar.bz2
Ishtar-cc0f377471c838076b8f28f113ba8ddf6ba4740f.zip
Shorten the label of files in operation list (refs #408)
-rw-r--r--archaeological_files/models.py4
-rw-r--r--archaeological_operations/models.py10
-rw-r--r--ishtar_common/views.py2
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
@@ -143,6 +143,10 @@ class File(BaseHistorizedItem, OwnPerms):
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),
unicode(self.numeric_reference or '0')))
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":