summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2015-02-16 04:24:05 +0100
committerÉtienne Loks <etienne.loks@proxience.com>2015-05-06 15:48:16 +0200
commit9ca3684e3edd18ac3e79426f019b9d0df6ad9067 (patch)
tree7305448c5f1917ee966f58a97ecb90d442fe5413
parentd580a4797ef5831a2151a5d481d65a161cd024f9 (diff)
downloadIshtar-9ca3684e3edd18ac3e79426f019b9d0df6ad9067.tar.bz2
Ishtar-9ca3684e3edd18ac3e79426f019b9d0df6ad9067.zip
Modify short label of archaeological files and operations (refs #2285)
-rw-r--r--archaeological_files/models.py2
-rw-r--r--archaeological_files/templates/ishtar/sheet_file.html6
-rw-r--r--archaeological_operations/models.py13
-rw-r--r--archaeological_operations/templates/ishtar/sheet_operation.html2
-rw-r--r--example_project/settings.py3
5 files changed, 17 insertions, 9 deletions
diff --git a/archaeological_files/models.py b/archaeological_files/models.py
index 5f402b9f1..a5f2c6c41 100644
--- a/archaeological_files/models.py
+++ b/archaeological_files/models.py
@@ -262,7 +262,7 @@ class File(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem,
@property
def reference(self):
- return u"-".join((unicode(self.year),
+ return settings.FILE_PREFIX+u"-".join((unicode(self.year),
unicode(self.numeric_reference or '0')))
def _generate_cached_label(self):
diff --git a/archaeological_files/templates/ishtar/sheet_file.html b/archaeological_files/templates/ishtar/sheet_file.html
index 736f982c5..2d7b6262d 100644
--- a/archaeological_files/templates/ishtar/sheet_file.html
+++ b/archaeological_files/templates/ishtar/sheet_file.html
@@ -102,7 +102,6 @@
<table>
<caption>{%trans "Associated operations"%}</caption>
<tr>
- <th>{% trans "Year" %}</th>
<th>{% trans "Ref." %}</th>
<th>Code Patriarche</th>
<th>{% trans "Type" %}</th>
@@ -113,9 +112,8 @@
</tr>
{% for operation in item.operations.all %}
<tr>
- <td>{{operation.year}}</td>
- <td>{{operation.operation_code}}</td>
- <td>{{operation.code_patriarche|default:""}}</td>
+ <td>{{operation.year_index}}</td>
+ <td>{{operation.full_code_patriarche|default:""}}</td>
<td class='string'>{{operation.operation_type}}</td>
<td class='string'>{{operation.in_charge|default:""}}</td>
<td>{{operation.start_date|default:""}}</td>
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index 9104b0d0d..53e572a20 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -204,7 +204,7 @@ class Operation(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem,
if settings.COUNTRY == 'fr':
code_patriarche = models.IntegerField(u"Code PATRIARCHE", null=True,
blank=True)
- TABLE_COLS = ['code_patriarche'] + TABLE_COLS
+ TABLE_COLS = ['full_code_patriarche'] + TABLE_COLS
code_dracar = models.CharField(u"Code DRACAR", max_length=10, null=True,
blank=True)
fnap_financing = models.FloatField(u"Financement FNAP (%)",
@@ -291,12 +291,13 @@ class Operation(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem,
def get_reference(self, full=False):
ref = ""
if self.code_patriarche:
- ref = unicode(self.code_patriarche)
+ ref = "OA" + unicode(self.code_patriarche)
if not full:
return ref
if self.year and self.operation_code:
if ref:
ref += u" - "
+ ref += settings.OP_PREFIX
ref += u"-".join((unicode(self.year),
unicode(self.operation_code)))
return ref or "00"
@@ -370,9 +371,15 @@ class Operation(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem,
return ""
lbl = unicode(self.operation_code)
year = self.year or 0
- lbl = u"%d-%s%s" % (year, (3-len(lbl))*"0", lbl)
+ lbl = settings.OP_PREFIX + u"%d-%s%s" % (year, (3-len(lbl))*"0", lbl)
return lbl
+ @property
+ def full_code_patriarche(self):
+ if not self.code_patriarche:
+ return ''
+ return u"OA" + unicode(self.code_patriarche)
+
def clean(self):
objs = self.__class__.objects.filter(year=self.year,
operation_code=self.operation_code)
diff --git a/archaeological_operations/templates/ishtar/sheet_operation.html b/archaeological_operations/templates/ishtar/sheet_operation.html
index 5f0626a02..cc69abda0 100644
--- a/archaeological_operations/templates/ishtar/sheet_operation.html
+++ b/archaeological_operations/templates/ishtar/sheet_operation.html
@@ -30,7 +30,7 @@
{% if item.year %}<p><label>{%trans "Year:"%}</label> <span class='value strong'>{{ item.year }}</span></p>{% endif %}
{% if item.operation_code %}<p><label>{%trans "Numerical reference:"%}</label> <span class='value strong'>{{ item.operation_code }}</span></p>{% endif %}
-{% if item.code_patriarche %}<p><label>{%trans "Patriarche OA code:"%}</label> <span class='value'>{{ item.code_patriarche }}</span></p>{%else%}
+{% if item.code_patriarche %}<p><label>{%trans "Patriarche OA code:"%}</label> <span class='value'>OA{{ item.code_patriarche }}</span></p>{%else%}
<p class='alert'>{%trans "Patriarche OA code not yet recorded!"%}</p>{%endif%}
<p><label>{%trans "Edition date:"%}</label> <span class='value'>{% if item.history_date %}{{ item.history_date }}{% else %}{{ item.history.all.0.history_date }}{% endif %}</span></p> <!-- date = now -->
diff --git a/example_project/settings.py b/example_project/settings.py
index 618c817df..5611be911 100644
--- a/example_project/settings.py
+++ b/example_project/settings.py
@@ -190,6 +190,9 @@ ISHTAR_DOC_TYPES = {u"undefined":u"Undefined"}
ISHTAR_DPTS = []
+OP_PREFIX = 'OP'
+FILE_PREFIX = 'SRA'
+
PRE_APPS = []
EXTRA_APPS = []