From 999eefae2632bb01a968d088ccd6406f7b0bc896 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 29 Jan 2015 00:08:22 +0100 Subject: Fix display of operations - fix bibracte import of operations --- archaeological_operations/data_importer.py | 3 ++- archaeological_operations/models.py | 3 ++- .../templates/ishtar/sheet_operation.html | 23 ++++++++++++++++------ ishtar_common/data_importer.py | 3 +-- ishtar_common/models.py | 2 ++ 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/archaeological_operations/data_importer.py b/archaeological_operations/data_importer.py index cad929d20..c1fd99fe1 100644 --- a/archaeological_operations/data_importer.py +++ b/archaeological_operations/data_importer.py @@ -173,7 +173,8 @@ class OperationImporterBibracte(Importer): # fin ImportFormater('excavation_end_date', DateFormater('%Y/%m/%d'),), # Chronos - ImportFormater('periods', TypeFormater(models.Period, many_split="&")), + ImportFormater('periods', TypeFormater(models.Period, many_split="&"), + required=False), ] RE_PARCEL_SECT_NUM = re.compile("([A-Za-z]*)([0-9]*)") diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 5d8c93ecf..5e3b05097 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -365,7 +365,8 @@ class Operation(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem, if not self.operation_code: return "" lbl = unicode(self.operation_code) - lbl = u"%d-%s%s" % (self.year, (3-len(lbl))*"0", lbl) + year = self.year or 0 + lbl = u"%d-%s%s" % (year, (3-len(lbl))*"0", lbl) return lbl def clean(self): diff --git a/archaeological_operations/templates/ishtar/sheet_operation.html b/archaeological_operations/templates/ishtar/sheet_operation.html index 138a94d14..5f0626a02 100644 --- a/archaeological_operations/templates/ishtar/sheet_operation.html +++ b/archaeological_operations/templates/ishtar/sheet_operation.html @@ -27,7 +27,7 @@

{% trans "General"%}

{% if item.common_name %}

{{ item.common_name }}

{% endif %} -

{{ item.year }}

+{% if item.year %}

{{ item.year }}

{% endif %} {% if item.operation_code %}

{{ item.operation_code }}

{% endif %} {% if item.code_patriarche %}

{{ item.code_patriarche }}

{%else%} @@ -90,7 +90,12 @@ {% endif %} {% trans "Document from this operation" as operation_docs %} -{% if item.source.count %} {% table_document operation_docs item.source.all %}{% endif %} +{% if item.source.count %} +{% table_document operation_docs item.source.all|slice:":15" %} +{% if item.source.count > 15 %} +Seuls les 15 premiers éléments ont été affichés sur un total de {{item.source.count}}. +{% endif %} +{% endif %} @@ -102,7 +107,7 @@ - {% for context_record in item.context_record.all %} + {% for context_record in item.context_record.all|slice:"15" %} @@ -115,9 +120,12 @@ {% endfor %}
{%trans "Context records"%}
{% trans "Parcel" %}  
{{ context_record.label }} {{context_record.unit|default:""}}
{% trans "No context record associated to this operation" %}
+{% if item.context_record.count > 15 %} +Seuls les 15 premiers éléments ont été affichés sur un total de {{item.context_record.count}}. +{% endif %} {% trans "Documents from associated context records" as cr_docs %} -{% if item.context_record_docs_q.count %} {% table_document cr_docs item.context_record_docs_q.all %}{% endif %} +{% if item.context_record_docs_q.count %} {% table_document cr_docs item.context_record_docs_q.all|slice:"15" %}{% endif %}
@@ -136,8 +144,8 @@ - {% for context_record in item.context_record.all %} - {% for find in context_record.base_finds.all %} + {% for context_record in item.context_record.all|slice:"5" %} + {% for find in context_record.base_finds.all|slice:"15" %} {# OPE|MAT.CODE|UE|FIND_index #} @@ -163,8 +171,11 @@ {% endfor %}
{% trans "Warehouse" %}  
{{ find.complete_id|default:""}}
+Seuls les 15 premiers éléments des 5 premières UEs sont affichées +{% comment %} {% trans "Documents from associated finds" as find_docs %} {% if item.find_docs_q.count %} {% table_document find_docs item.find_docs_q.all %}{% endif %} +{% endcomment %} {% endblock %} diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index cde464e04..c2924a541 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -673,8 +673,7 @@ class Importer(object): values = [v] many_values = getattr(func, 'many_split', None) if many_values: - values = re.compile(func.many_split).split(values) - + values = re.split(func.many_split, values[0]) formated_values = [] for idx, v in enumerate(values): value = None diff --git a/ishtar_common/models.py b/ishtar_common/models.py index ab558ce75..af43f28e9 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1132,6 +1132,8 @@ class Person(Address, Merge, OwnPerms, ValueGetter) : values += [unicode(getattr(self, attr)) for attr in ('surname', 'name') if getattr(self, attr)] + if not values and self.raw_name: + values = [self.raw_name] if self.attached_to: values.append(u"- " + unicode(self.attached_to)) return u" ".join(values) -- cgit v1.2.3