diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-01-03 16:58:16 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-01-03 16:58:16 +0100 |
commit | 559d5388f0cd502da3eae25ed30cc5e005e26f76 (patch) | |
tree | 9b95b642df6e027571f2e9ad0216963a2f1ec3fc | |
parent | 70950a81ebbb1dbebc259b8226fe19d358944db6 (diff) | |
download | Ishtar-559d5388f0cd502da3eae25ed30cc5e005e26f76.tar.bz2 Ishtar-559d5388f0cd502da3eae25ed30cc5e005e26f76.zip |
Permissions: fix permission for context record, operation, sites associated to a find basket
5 files changed, 24 insertions, 4 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index 2e9af17c1..d7d7a618d 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -538,6 +538,9 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem, def get_query_owns(cls, ishtaruser): q = cls._construct_query_own( 'operation__', Operation._get_query_owns_dicts(ishtaruser) + ) | cls._construct_query_own( + 'base_finds__find__basket__', + [{"shared_with": ishtaruser, "shared_write_with": ishtaruser}] ) | cls._construct_query_own('', [ {'history_creator': ishtaruser.user_ptr}, {'operation__end_date__isnull': True} diff --git a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html index 2ad74b7d2..af5da11dd 100644 --- a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html +++ b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html @@ -171,9 +171,11 @@ {% endif %} {% trans "Document from this context record" as cr_docs %} +{% if permission_view_own_document or permission_view_document %} {% if item.documents.count %} {% dynamic_table_document cr_docs 'documents' 'context_records' item.pk '' output %} {% endif %} +{% endif %} {% trans "Finds" as finds %} {% if item.base_finds.count %} @@ -181,8 +183,10 @@ {% endif %} {% trans "Documents from associated finds" as finds_docs %} +{% if permission_view_own_document or permission_view_document %} {% if item.find_docs_q.count %} {% dynamic_table_document finds_docs 'documents' 'finds__base_finds__context_record' item.pk '' output %} {% endif %} +{% endif %} {% endblock %} diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html index b676d6235..66fcca33e 100644 --- a/archaeological_finds/templates/ishtar/sheet_find.html +++ b/archaeological_finds/templates/ishtar/sheet_find.html @@ -48,7 +48,7 @@ </a> </li> {% endif %} - {% if item.documents.count %} + {% if permission_view_own_document or permission_view_document %}{% if item.documents.count %} <li class="nav-item"> <a class="nav-link" id="{{window_id}}-documents-tab" data-toggle="tab" href="#{{window_id}}-documents" role="tab" @@ -56,7 +56,7 @@ {% trans "Documents" %} </a> </li> - {% endif %} + {% endif %}{% endif %} <li class="nav-item"> <a class="nav-link" id="{{window_id}}-json-tab" data-toggle="tab" href="#{{window_id}}-json" role="tab" @@ -365,13 +365,13 @@ {% endif %} {% endif %} </div> - {% if item.documents.count %} + {% if permission_view_own_document or permission_view_document %}{% if item.documents.count %} <div class="tab-pane fade" id="{{window_id}}-documents" role="tabpanel" aria-labelledby="{{window_id}}-documents-tab"> {% trans "Associated documents" as finds_docs %} {% dynamic_table_document finds_docs 'documents' 'finds' item.pk '' output %} </div> - {% endif %} + {% endif %}{% endif %} <div class="tab-pane fade" id="{{window_id}}-json" role="tabpanel" aria-labelledby="{{window_id}}-json-tab"> {% include "ishtar/blocks/sheet_json.html" %} diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index adcadccd7..d8233ba0f 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -305,6 +305,9 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter, 'operations__context_record__base_finds__find__container__responsible__', Warehouse._get_query_owns_dicts(ishtaruser) ) | cls._construct_query_own( + 'operations__context_record__base_finds__find__basket__', + [{"shared_with": ishtaruser, "shared_write_with": ishtaruser}] + ) | cls._construct_query_own( 'operations__context_record__base_finds__find__container__location__', Warehouse._get_query_owns_dicts(ishtaruser) ) | cls._construct_query_own( @@ -1171,6 +1174,9 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, 'context_record__base_finds__find__container__location__', Warehouse._get_query_owns_dicts(ishtaruser) ) | cls._construct_query_own( + 'context_record__base_finds__find__basket__', + [{"shared_with": ishtaruser, "shared_write_with": ishtaruser}] + ) | cls._construct_query_own( '', cls._get_query_owns_dicts(ishtaruser) ) return q diff --git a/archaeological_operations/templates/ishtar/sheet_operation.html b/archaeological_operations/templates/ishtar/sheet_operation.html index 1d699cbed..8801855cd 100644 --- a/archaeological_operations/templates/ishtar/sheet_operation.html +++ b/archaeological_operations/templates/ishtar/sheet_operation.html @@ -207,9 +207,11 @@ {% endif %} {% trans "Document from this operation" as operation_docs %} +{% if permission_view_own_document or permission_view_document %} {% if item.documents.count %} {% dynamic_table_document operation_docs 'documents' 'operations' item.pk '' output %} {% endif %} +{% endif %} {% if permission_view_own_contextrecord or permission_view_contextrecord %} {% if item.context_record.count %} @@ -222,21 +224,26 @@ {% dynamic_table_document cr_rels 'context_records_relations_detail' 'left_record__operation' item.pk '' output %} {% endif %} +{% if permission_view_own_document or permission_view_document %} {% if item.context_record_docs_q.count %} {% trans "Documents from associated context records" as cr_docs %} {% dynamic_table_document cr_docs 'documents' 'context_records__operation' item.pk '' output %} {% endif %} {% endif %} +{% endif %} + {% if item.finds %} {% trans "Finds" as finds %} {% dynamic_table_document finds 'finds_for_ope' 'base_finds__context_record__operation' item.pk 'TABLE_COLS_FOR_OPE' output %} {% endif %} +{% if permission_view_own_document or permission_view_document %} {% if item.find_docs_q.count %} {% trans "Documents from associated finds" as finds_docs %} {% dynamic_table_document finds_docs 'documents' 'finds__base_finds__context_record__operation' item.pk '' output %} {% endif %} +{% endif %} {% if permission_view_own_container or permission_view_container %} {% if item.containers_q.count %} |