summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2015-12-07 19:33:36 +0100
committerÉtienne Loks <etienne.loks@proxience.com>2015-12-07 19:33:36 +0100
commit0e8b89cc3db520537e96157c178a4985c644b7ce (patch)
tree4cc2973c93352fea7f36ac628ad7969006afa82b
parentaca19bb95c45d6696179696ebfd7d099ec849310 (diff)
downloadIshtar-0e8b89cc3db520537e96157c178a4985c644b7ce.tar.bz2
Ishtar-0e8b89cc3db520537e96157c178a4985c644b7ce.zip
Person sheet: better management of related operations and files
-rw-r--r--ishtar_common/templates/ishtar/sheet_person.html67
-rw-r--r--ishtar_common/templatetags/window_tables.py9
2 files changed, 22 insertions, 54 deletions
diff --git a/ishtar_common/templates/ishtar/sheet_person.html b/ishtar_common/templates/ishtar/sheet_person.html
index 38bc39c58..126afe83a 100644
--- a/ishtar_common/templates/ishtar/sheet_person.html
+++ b/ishtar_common/templates/ishtar/sheet_person.html
@@ -1,5 +1,5 @@
{% extends "ishtar/sheet.html" %}
-{% load i18n window_field %}
+{% load i18n window_field window_tables %}
{% block head_sheet %}
{{block.super}}
@@ -33,59 +33,20 @@
{% endif %}
-<table>
- <caption>{%trans "Associated operations"%}</caption>
- <tr>
- <th>{% trans "Year" %}</th>
- <th>{% trans "Ref." %}</th>
- <th>Code Patriarche</th>
- <th>{% trans "Type" %}</th>
- <th>{% trans "In charge" %}</th>
- <th>{% trans "Start date" %}</th>
- <th>{% trans "Excavation end date" %}</th>
- <th class='link'>&nbsp;</th>
- </tr>
- {% for operation in item.operation_scientific_responsability.all %}
- <tr>
- <td>{{operation.year|default:""}}</td>
- <td>{{operation.operation_code|default:""}}</td>
- <td>{{operation.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>
- <td>{{operation.excavation_end_date|default:""}}</td>
- <td class='link'><a href="#" class='display_details' onclick='load_window("{%url show-operation operation.pk ''%}")'>{% trans "Details" %}</a></td>
- </tr>
- {% empty %}
- <tr><td colspan="8" class='no_items'>{% trans "No operation associated to this person" %}</td></tr>
- {% endfor %}
-</table>
+{% trans "Associated operations as scientist" as ao %}
+{% if item.operation_scientist_responsability.count %}
+{% dynamic_table_document ao 'operations' 'operation_scientist_responsability' item.pk %}
+{% endif %}
+{% trans "Associated operations as responsible" as ao %}
+{% if item.operation_responsability.count %}
+{% dynamic_table_document ao 'operations' 'operation_responsability' item.pk %}
+{% endif %}
-<table>
- <caption>{%trans "Associated archaelogical files"%}</caption>
- <tr>
- <th>{% trans "Ref." %}</th>
- <th>{% trans "Year" %}</th>
- <th>{% trans "Internal ref." %}</th>
- <th>{% trans "File type" %}</th>
- <th>Type de saisine</th>
- <th>{% trans "Towns" %}</th>
- <th class='link'>&nbsp;</th>
- </tr>
- {% for file in item.file_responsability.all %}
- <tr>
- <td>{{file.numeric_reference}}</td>
- <td>{{file.year}}</td>
- <td>{{file.internal_reference}}</td>
- <td>{{file.file_type}}</td>
- <td>{{file.saisine_type}}</td>
- <td class='string'>{{file.town_list}}</td>
- <td class='link'><a href="#" onclick='load_window("{%url show-file file.pk ''%}")'>{% trans "Details" %}</a></td>
- </tr>
- {% empty %}
- <tr><td colspan="8" class='no_items'>{% trans "No archaelogical file associated to this person" %}</td></tr>
- {% endfor %}
-</table>
+
+{% trans "Associated archaelogical files" as af %}
+{% if item.file_responsability.count %}
+{% dynamic_table_document af 'files' 'file_responsability' item.pk %}
+{% endif %}
<table>
<caption>{%trans "Documents"%}</caption>
diff --git a/ishtar_common/templatetags/window_tables.py b/ishtar_common/templatetags/window_tables.py
index 32a3076c5..a1aa735a7 100644
--- a/ishtar_common/templatetags/window_tables.py
+++ b/ishtar_common/templatetags/window_tables.py
@@ -17,9 +17,16 @@ def table_document(caption, data):
ASSOCIATED_MODELS = {}
try:
- from archaeological_operations.models import OperationSource
+ from archaeological_files.models import File
+ ASSOCIATED_MODELS['files'] = (File, 'get-file', '')
+except:
+ pass
+
+try:
+ from archaeological_operations.models import OperationSource, Operation
ASSOCIATED_MODELS['operation_docs'] = (OperationSource,
'get-operationsource', '')
+ ASSOCIATED_MODELS['operations'] = (Operation, 'get-operation', '')
except:
pass