diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-01-09 18:09:37 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-01-09 18:11:10 +0100 |
commit | 0575bbf4fe3bef6fee38212193786863908ba599 (patch) | |
tree | c65b5086bd4db147751de5a0d7d1b578d9c8944e | |
parent | 8e4d2ca13b65f48534ad0b36b1850b2ce8a20949 (diff) | |
download | Ishtar-0575bbf4fe3bef6fee38212193786863908ba599.tar.bz2 Ishtar-0575bbf4fe3bef6fee38212193786863908ba599.zip |
Contex record: fix relation tables
-rw-r--r-- | archaeological_context_records/models.py | 17 | ||||
-rw-r--r-- | archaeological_context_records/urls.py | 3 | ||||
-rw-r--r-- | archaeological_context_records/views.py | 4 | ||||
-rw-r--r-- | archaeological_operations/templates/ishtar/sheet_operation.html | 2 | ||||
-rw-r--r-- | ishtar_common/templatetags/window_tables.py | 5 | ||||
-rw-r--r-- | ishtar_common/views.py | 2 |
6 files changed, 24 insertions, 9 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index 5e4d31c3b..cf39870ca 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -128,8 +128,9 @@ class ContextRecord(BaseHistorizedItem, ImageModel, OwnPerms, if settings.COUNTRY == 'fr': TABLE_COLS.insert(1, 'operation__code_patriarche') TABLE_COLS_FOR_OPE = ['label', 'parcel', 'unit', - 'datings__period', 'description'] - COL_LABELS = {'section__parcel_number': _("Parcel")} + 'datings__period__label', 'description'] + COL_LABELS = {'section__parcel_number': _(u"Parcel"), + 'datings__period__label': _(u"Periods")} CONTEXTUAL_TABLE_COLS = { 'full': { 'related_context_records': 'detailled_related_context_records' @@ -401,10 +402,9 @@ class RecordRelations(GeneralRecordRelations, models.Model): 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"] + ] COL_LABELS = { "left_record__label": _(u"ID (left)"), "left_record__unit": _(u"Unit (left)"), @@ -412,8 +412,8 @@ class RecordRelations(GeneralRecordRelations, models.Model): "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__label": _(u"ID (right)"), + "right_record__unit": _(u"Unit (right)"), "right_record__parcel": _(u"Parcel (right)"), "right_record__description": _(u"Description (right)"), "right_record__datings__period": _(u"Periods (right)") @@ -456,6 +456,11 @@ class RecordRelationView(models.Model): "right_record__description": _(u"Description"), "right_record__datings__period": _(u"Periods") } + + # search parameters + EXTRA_REQUEST_KEYS = { + "left_record_id": "left_record_id" + } left_record = models.ForeignKey(ContextRecord, related_name='+', on_delete=models.DO_NOTHING) right_record = models.ForeignKey(ContextRecord, related_name='+', diff --git a/archaeological_context_records/urls.py b/archaeological_context_records/urls.py index 8cfb1b391..341d321f9 100644 --- a/archaeological_context_records/urls.py +++ b/archaeological_context_records/urls.py @@ -97,6 +97,9 @@ urlpatterns += patterns( kwargs={'full': 'shortcut'}), url(r'get-contextrecordrelation/(?P<type>.+)?$', 'get_contextrecordrelation', name='get-contextrecordrelation'), + url(r'get-contextrecordrelationdetail/(?P<type>.+)?$', + 'get_contextrecordrelationdetail', + name='get-contextrecordrelationdetail'), 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 b79cd2671..cf3a13b3b 100644 --- a/archaeological_context_records/views.py +++ b/archaeological_context_records/views.py @@ -83,6 +83,10 @@ get_contextrecordrelation = get_item( models.RecordRelationView, 'get_contextrecordrelation', 'contextrecordrelation') +get_contextrecordrelationdetail = get_item( + models.RecordRelations, 'get_contextrecordrelationdetail', + 'contextrecordrelationdetail') + record_search_wizard = SearchWizard.as_view([ ('general-record_search', RecordFormSelection)], label=_(u"Context record search"), diff --git a/archaeological_operations/templates/ishtar/sheet_operation.html b/archaeological_operations/templates/ishtar/sheet_operation.html index 4fc6c1a28..43446c516 100644 --- a/archaeological_operations/templates/ishtar/sheet_operation.html +++ b/archaeological_operations/templates/ishtar/sheet_operation.html @@ -115,7 +115,7 @@ {% trans "Context record relations" as cr_rels %} {% if item.context_record_relations_q.count %} -{% dynamic_table_document cr_rels 'context_records_relations' 'left_record__operation' item.pk '' output %} +{% dynamic_table_document cr_rels 'context_records_relations_detail' 'left_record__operation' item.pk '' output %} {% endif %} {% trans "Documents from associated context records" as cr_docs %} diff --git a/ishtar_common/templatetags/window_tables.py b/ishtar_common/templatetags/window_tables.py index fc2ba3874..2fc364f25 100644 --- a/ishtar_common/templatetags/window_tables.py +++ b/ishtar_common/templatetags/window_tables.py @@ -15,7 +15,8 @@ from ishtar_common.widgets import JQueryJqGrid from archaeological_files.models import File from archaeological_operations.models import OperationSource, Operation from archaeological_context_records.models import ContextRecord, \ - ContextRecordSource, RecordRelationView + ContextRecordSource, RecordRelationView, \ + RecordRelations as CRRecordRelations from archaeological_finds.models import Find, FindSource, \ FindUpstreamTreatments, FindDownstreamTreatments, FindTreatments from archaeological_warehouse.models import Container @@ -42,6 +43,8 @@ ASSOCIATED_MODELS['context_records_docs'] = ( 'get-contextrecordsource', 'get-contextrecordsource-full') ASSOCIATED_MODELS['context_records_relations'] = ( RecordRelationView, 'get-contextrecordrelation', '') +ASSOCIATED_MODELS['context_records_relations_detail'] = ( + CRRecordRelations, 'get-contextrecordrelationdetail', '') ASSOCIATED_MODELS['finds'] = (Find, 'get-find', 'get-find-full') ASSOCIATED_MODELS['finds_for_ope'] = ( diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 5f37a4dbf..1e272fc78 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -827,7 +827,7 @@ def get_item(model, func_name, default_name, extra_request_keys=[], and request.session[model_name] if current: dct = {upper_key: current} - query = query & Q(**dct) + query &= Q(**dct) items = model.objects.filter(query).distinct() # print(items.query) |