From 9c610680263e68346a28bbae8e7a76cf3c9a8b35 Mon Sep 17 00:00:00 2001 From: Ross Date: Fri, 27 Sep 2024 08:14:06 +0100 Subject: [PATCH] let people view open access series --- atlas/decorators.py | 3 +- atlas/templates/atlas/series.html | 4 +- atlas/templates/atlas/series_viewer.html | 132 ++++++++++++----------- atlas/urls.py | 1 + atlas/views.py | 9 +- 5 files changed, 82 insertions(+), 67 deletions(-) diff --git a/atlas/decorators.py b/atlas/decorators.py index 5c063341..16c6b4fa 100755 --- a/atlas/decorators.py +++ b/atlas/decorators.py @@ -2,11 +2,12 @@ from django.core.exceptions import PermissionDenied from .models import Case, CaseCollection, Series -def user_is_author_or_atlas_series_checker_or_atlas_marker(function): +def user_is_author_or_atlas_series_checker_or_atlas_marker_or_open_access(function): def wrap(request, *args, **kwargs): series = Series.objects.get(pk=kwargs["pk"]) if ( request.user in series.get_author_objects() + or series.open_access or request.user.groups.filter(name="atlas_editor").exists() or request.user.groups.filter(name="atlas_marker").exists() or request.user.is_superuser diff --git a/atlas/templates/atlas/series.html b/atlas/templates/atlas/series.html index f91f579e..9cd9ff22 100755 --- a/atlas/templates/atlas/series.html +++ b/atlas/templates/atlas/series.html @@ -4,7 +4,9 @@ {% block navigation%} {{ block.super }} - {% include 'atlas/series_headers.html' %} + {% if can_edit %} + {% include 'atlas/series_headers.html' %} + {% endif %} {% endblock %} {% block content %} diff --git a/atlas/templates/atlas/series_viewer.html b/atlas/templates/atlas/series_viewer.html index 65bd1e66..d3aba48b 100755 --- a/atlas/templates/atlas/series_viewer.html +++ b/atlas/templates/atlas/series_viewer.html @@ -16,20 +16,24 @@
- {% if editing_finding < 1 %} - - {% endif %} - -
-
-
- {% csrf_token %} - {{series_finding_form|crispy}} - - -
+ {% if can_edit %} + {% if editing_finding < 1 %} + + {% endif %} + +
+
+
+ {% csrf_token %} + {{series_finding_form|crispy}} + + +
+
-
+ {% else %} + + {% endif %}
Findings @@ -47,43 +51,46 @@ Structure(s): {% for s in finding.structures.all %}{{s.get_link}}{% endfor %}
Condition(s): {% for s in finding.conditions.all %}{{s.get_link}}{% endfor %}
Description: {{finding.description}}
- - {% if request.user.is_superuser %} - + - + {% endif %} - Edit - - - Delete + {% if can_edit %} + Edit + Delete + {% endif %}
{% endfor %} -
- Truncate series -

- This will limit the series to the selected bounds (the rest of the images will be deleted). This is useful when you have a large volume of which only a small area is relevant to the case. NOTE: once deleted the images cannot be recovered on the site (they would have to be reuploaded if required). Make sure your images are shown in the correct order above and use test the test truncate button first. -

- Start
- End
- - -
+ {% if can_edit %} +
+ Truncate series +

+ This will limit the series to the selected bounds (the rest of the images will be deleted). This is useful when you have a large volume of which only a small area is relevant to the case. NOTE: once deleted the images cannot be recovered on the site (they would have to be reuploaded if required). Make sure your images are shown in the correct order above and use test the test truncate button first. +

+ Start
+ End
+ + +
-
+
+ {% endif %} {% endwith %}
Author: {{ series.get_author_display }}
+ {% if can_edit %}
Series info
@@ -105,25 +112,25 @@ Image details
- {% for image in series.get_images %} - [{{ image.id }}] {{image.image.url}}, pos: {{image.position}}, {{image.upload_filename}} + {% for image in series.get_images %} + [{{ image.id }}] {{image.image.url}}, pos: {{image.position}}, {{image.upload_filename}} - {% if image.image %} - [{{image.get_file_size|filesizeformat}}] - {% endif %} + {% if image.image %} + [{{image.get_file_size|filesizeformat}}] + {% endif %} - {{image.image_md5_hash}} ({{image.is_dicom}}) {{image.image_blake3_hash}} + {{image.image_md5_hash}} ({{image.is_dicom}}) {{image.image_blake3_hash}} - + -
+
{% comment %} {{image.get_dicom_info|safe}}
{% endcomment %} - {% endfor %} - + {% endfor %} +
@@ -131,21 +138,22 @@

Total image size: {{series.get_total_image_size|filesizeformat}}

Download images

- show all diff +show all diff +{% endif %}