summaryrefslogtreecommitdiff
path: root/archaeological_context_records
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-10-16 23:29:41 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-10-16 23:29:41 +0200
commit78cb0d4794a80c99e17f96a06e68951d5221d0f8 (patch)
treeceac818ab232d6fb74289ab31571de56086d7bb5 /archaeological_context_records
parentc5bf89a4177c3f40a9b02e721bdcc5e85fc136bf (diff)
downloadIshtar-78cb0d4794a80c99e17f96a06e68951d5221d0f8.tar.bz2
Ishtar-78cb0d4794a80c99e17f96a06e68951d5221d0f8.zip
List and export context record relations (refs #3329)
Diffstat (limited to 'archaeological_context_records')
-rw-r--r--archaeological_context_records/forms.py2
-rw-r--r--archaeological_context_records/models.py19
-rw-r--r--archaeological_context_records/templates/ishtar/sheet_contextrecord.html30
-rw-r--r--archaeological_context_records/urls.py2
-rw-r--r--archaeological_context_records/views.py7
5 files changed, 32 insertions, 28 deletions
diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py
index d468e3a3c..4a5267654 100644
--- a/archaeological_context_records/forms.py
+++ b/archaeological_context_records/forms.py
@@ -214,7 +214,7 @@ class RecordFormGeneral(ManageOldType, forms.Form):
cr = models.ContextRecord.objects.filter(
label=label, parcel__operation__pk=operation_id)
if 'pk' in cleaned_data and cleaned_data['pk']:
- cr = cr.exclude(pk=cleaned_data['pk'])
+ cr = cr.exclude(pk=int(cleaned_data['pk']))
if cr.count():
raise forms.ValidationError(_(u"This ID already exists for "
u"this operation."))
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index 5dc943275..e1cb216a2 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -363,6 +363,25 @@ class RecordRelations(GeneralRecordRelations, models.Model):
right_record = models.ForeignKey(ContextRecord,
related_name='left_relations')
relation_type = models.ForeignKey(RelationType)
+ TABLE_COLS = [
+ "left_record__label", "left_record__unit", "left_record__parcel",
+ "left_record__datings__period", "left_record__description",
+ "relation_type",
+ "right_record__label", "right_record__unit", "right_record__parcel",
+ "right_record__datings__period", "right_record__description"]
+ TABLE_COLS_LBL = {
+ "left_record__label": _(u"ID (left)"),
+ "left_record__unit": _(u"Unit (left)"),
+ "left_record__parcel": _(u"Parcel (left)"),
+ "left_record__description": _(u"Description (left)"),
+ "left_record__datings__period": _(u"Periods (left)"),
+ "relation_type": _(u"Relation type"),
+ "right_record__label": _(u"Unit (right)"),
+ "right_record__unit": _(u"Parcel (right)"),
+ "right_record__parcel": _(u"Parcel (right)"),
+ "right_record__description": _(u"Description (right)"),
+ "right_record__datings__period": _(u"Periods (right)")
+ }
class Meta:
verbose_name = _(u"Record relation")
diff --git a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html
index bd883ac0b..907697c9e 100644
--- a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html
+++ b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html
@@ -55,36 +55,12 @@
</ul>
{% endif %}
+{% trans "Context record relations" as cr_rels %}
{% if item.right_relations.count %}
-<h3>{% trans "In relation with"%}</h3>
-<div class='clean-table'>
-<div class='clean-table-wrap'>
-<table>
- <tr>
- <th>{% trans "Relation type" %}</th>
- <th>{% trans "ID" %}</th>
- <th>{% trans "Type" %}</th>
- <th>{% trans "Chronology" %}</th>
- <th>{% trans "Description" %}</th>
- <th>{% trans "Parcel" %}</th>
- <th class='link'>&nbsp;</th>
- </tr>
- {% for relation in item.right_relations.all %}
- <tr>
- <td class='string'>{{ relation.relation_type }}</td>
- <td class='string'>{{ relation.right_record.label }}</td>
- <td class='string'>{{relation.right_record.unit|default:""}}</td>
- <td class='string'>{{ relation.right_record.datings.all|join:", " }}</td>{# periods ?#}
- <td class='string'>{{ relation.right_record.description }}</td>
- <td class='string'>{{ relation.right_record.parcel.section }} - {{relation.right_record.parcel.parcel_number}}</td>
- <td class='link'><a href="#" class='display_details' onclick='load_window("{%url show-contextrecord relation.right_record.pk ''%}")'><i class="fa fa-info-circle" aria-hidden="true"></i></a></td>
- </tr>
- {% endfor %}
-</table>
-</div></div>
-
+{% dynamic_table_document cr_rels 'context_records_relations' 'left_record' item.pk '' output %}
{% endif %}
+
{% if item.operation %}
<h3>{% trans "Operation summary"%}</h3>
{% if not item.operation.code_patriarche %}
diff --git a/archaeological_context_records/urls.py b/archaeological_context_records/urls.py
index a25559e29..24e8e06eb 100644
--- a/archaeological_context_records/urls.py
+++ b/archaeological_context_records/urls.py
@@ -92,6 +92,8 @@ urlpatterns += patterns(
url(r'get-contextrecord-shortcut/(?P<type>.+)?$',
'get_contextrecord', name='get-contextrecord-shortcut',
kwargs={'full': 'shortcut'}),
+ url(r'get-contextrecordrelation/(?P<type>.+)?$',
+ 'get_contextrecordrelation', name='get-contextrecordrelation'),
url(r'show-contextrecordsource(?:/(?P<pk>.+))?/(?P<type>.+)?$',
'show_contextrecordsource', name=models.ContextRecordSource.SHOW_URL),
url(r'get-contexrecordsource/(?P<type>.+)?$',
diff --git a/archaeological_context_records/views.py b/archaeological_context_records/views.py
index bc95473e6..0ced39b20 100644
--- a/archaeological_context_records/views.py
+++ b/archaeological_context_records/views.py
@@ -121,6 +121,13 @@ get_contextrecordsource = get_item(
'context_record__unit': 'context_record__unit__pk',
})
+get_contextrecordrelation = get_item(
+ models.RecordRelations, 'get_contextrecordrelation',
+ 'contextrecordrelation',
+ extra_request_keys={
+ "left_record__operation": "left_record__operation__pk"
+ })
+
record_search_wizard = SearchWizard.as_view([
('general-record_search', RecordFormSelection)],
label=_(u"Context record search"),