let people view open access series
This commit is contained in:
+2
-1
@@ -2,11 +2,12 @@ from django.core.exceptions import PermissionDenied
|
|||||||
from .models import Case, CaseCollection, Series
|
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):
|
def wrap(request, *args, **kwargs):
|
||||||
series = Series.objects.get(pk=kwargs["pk"])
|
series = Series.objects.get(pk=kwargs["pk"])
|
||||||
if (
|
if (
|
||||||
request.user in series.get_author_objects()
|
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_editor").exists()
|
||||||
or request.user.groups.filter(name="atlas_marker").exists()
|
or request.user.groups.filter(name="atlas_marker").exists()
|
||||||
or request.user.is_superuser
|
or request.user.is_superuser
|
||||||
|
|||||||
@@ -4,7 +4,9 @@
|
|||||||
{% block navigation%}
|
{% block navigation%}
|
||||||
|
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
{% if can_edit %}
|
||||||
{% include 'atlas/series_headers.html' %}
|
{% include 'atlas/series_headers.html' %}
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
<div id="single-dicom-viewer" class="dicom-viewer" data-images="{{ image_url_array_and_count.0 }}" data-annotations=''>
|
<div id="single-dicom-viewer" class="dicom-viewer" data-images="{{ image_url_array_and_count.0 }}" data-annotations=''>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if can_edit %}
|
||||||
{% if editing_finding < 1 %}
|
{% if editing_finding < 1 %}
|
||||||
<button id="add-finding-button">Add finding</button>
|
<button id="add-finding-button">Add finding</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -30,6 +31,9 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<button id="reset-viewport-button">Reset viewport</button>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<details open>
|
<details open>
|
||||||
<summary>Findings</summary>
|
<summary>Findings</summary>
|
||||||
@@ -60,14 +64,15 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
|
{% if can_edit %}
|
||||||
<a href="{% url 'atlas:series_edit_finding' pk=series.pk finding_pk=finding.pk %}" class="edit-finding-link">Edit</a>
|
<a href="{% url 'atlas:series_edit_finding' pk=series.pk finding_pk=finding.pk %}" class="edit-finding-link">Edit</a>
|
||||||
|
|
||||||
|
|
||||||
<a href="{% url 'atlas:delete_finding' pk=finding.pk %}" class="delete-finding-link">Delete</a>
|
<a href="{% url 'atlas:delete_finding' pk=finding.pk %}" class="delete-finding-link">Delete</a>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</details>
|
</details>
|
||||||
|
{% if can_edit %}
|
||||||
<details>
|
<details>
|
||||||
<summary>Truncate series</summary>
|
<summary>Truncate series</summary>
|
||||||
<p>
|
<p>
|
||||||
@@ -80,10 +85,12 @@
|
|||||||
<div id="truncate-output"></div>
|
<div id="truncate-output"></div>
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
{% endif %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
|
|
||||||
<div>Author: {{ series.get_author_display }}</div>
|
<div>Author: {{ series.get_author_display }}</div>
|
||||||
|
{% if can_edit %}
|
||||||
<details>
|
<details>
|
||||||
<summary>Series info</summary>
|
<summary>Series info</summary>
|
||||||
<div>
|
<div>
|
||||||
@@ -146,6 +153,7 @@
|
|||||||
end
|
end
|
||||||
">diff</span></span>
|
">diff</span></span>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|||||||
@@ -297,6 +297,7 @@ urlpatterns = [
|
|||||||
),
|
),
|
||||||
path("structure/create", views.StructureCreate.as_view(), name="structure_create"),
|
path("structure/create", views.StructureCreate.as_view(), name="structure_create"),
|
||||||
path("series/<int:pk>/thumbnail", views.series_thumbnail, name="series_thumbnail"),
|
path("series/<int:pk>/thumbnail", views.series_thumbnail, name="series_thumbnail"),
|
||||||
|
# TODO: case context series viewing (so that we can view series in the context of a case)
|
||||||
path("series/<int:pk>", views.series_detail, name="series_detail"),
|
path("series/<int:pk>", views.series_detail, name="series_detail"),
|
||||||
path("series/<int:pk>/authors", views.SeriesAuthorUpdate.as_view(), name="series_authors"),
|
path("series/<int:pk>/authors", views.SeriesAuthorUpdate.as_view(), name="series_authors"),
|
||||||
path("series/", views.SeriesView.as_view(), name="series_view"),
|
path("series/", views.SeriesView.as_view(), name="series_view"),
|
||||||
|
|||||||
+6
-3
@@ -121,7 +121,7 @@ from autocomplete import HTMXAutoComplete
|
|||||||
from .decorators import (
|
from .decorators import (
|
||||||
user_is_author_or_atlas_editor,
|
user_is_author_or_atlas_editor,
|
||||||
user_has_case_view_access,
|
user_has_case_view_access,
|
||||||
user_is_author_or_atlas_series_checker_or_atlas_marker,
|
user_is_author_or_atlas_series_checker_or_atlas_marker_or_open_access,
|
||||||
user_is_atlas_editor,
|
user_is_atlas_editor,
|
||||||
user_is_author_or_atlas_series_checker,
|
user_is_author_or_atlas_series_checker,
|
||||||
user_is_atlas_marker,
|
user_is_atlas_marker,
|
||||||
@@ -198,7 +198,7 @@ def case_detail(request, pk):
|
|||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@user_is_author_or_atlas_series_checker_or_atlas_marker
|
@user_is_author_or_atlas_series_checker_or_atlas_marker_or_open_access
|
||||||
def series_thumbnail(request, pk, finding_pk=None):
|
def series_thumbnail(request, pk, finding_pk=None):
|
||||||
series = get_object_or_404(Series, pk=pk)
|
series = get_object_or_404(Series, pk=pk)
|
||||||
|
|
||||||
@@ -208,10 +208,12 @@ def series_thumbnail(request, pk, finding_pk=None):
|
|||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@user_is_author_or_atlas_series_checker_or_atlas_marker
|
@user_is_author_or_atlas_series_checker_or_atlas_marker_or_open_access
|
||||||
def series_detail(request, pk, finding_pk=None):
|
def series_detail(request, pk, finding_pk=None):
|
||||||
series = get_object_or_404(Series, pk=pk)
|
series = get_object_or_404(Series, pk=pk)
|
||||||
|
|
||||||
|
can_edit = series.check_user_can_edit(request.user)
|
||||||
|
|
||||||
editing_finding = -1
|
editing_finding = -1
|
||||||
if finding_pk is not None:
|
if finding_pk is not None:
|
||||||
finding = get_object_or_404(SeriesFinding, pk=finding_pk)
|
finding = get_object_or_404(SeriesFinding, pk=finding_pk)
|
||||||
@@ -228,6 +230,7 @@ def series_detail(request, pk, finding_pk=None):
|
|||||||
"series": series,
|
"series": series,
|
||||||
"series_finding_form": series_finding_form,
|
"series_finding_form": series_finding_form,
|
||||||
"editing_finding": editing_finding,
|
"editing_finding": editing_finding,
|
||||||
|
"can_edit": can_edit,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user