Compare commits

...
2 Commits
Author SHA1 Message Date
Ross 9c61068026 let people view open access series 2024-09-27 08:14:06 +01:00
Ross 24590ee2b1 fix crispy templates (finally...) 2024-09-27 08:13:57 +01:00
6 changed files with 83 additions and 68 deletions
+2 -1
View File
@@ -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
+2
View File
@@ -4,7 +4,9 @@
{% block navigation%}
{{ block.super }}
{% if can_edit %}
{% include 'atlas/series_headers.html' %}
{% endif %}
{% endblock %}
{% block content %}
+10 -2
View File
@@ -16,6 +16,7 @@
<div id="single-dicom-viewer" class="dicom-viewer" data-images="{{ image_url_array_and_count.0 }}" data-annotations=''>
</div>
{% if can_edit %}
{% if editing_finding < 1 %}
<button id="add-finding-button">Add finding</button>
{% endif %}
@@ -30,6 +31,9 @@
</form>
</div>
</div>
{% else %}
<button id="reset-viewport-button">Reset viewport</button>
{% endif %}
<details open>
<summary>Findings</summary>
@@ -60,14 +64,15 @@
</div>
{% endif %}
</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:delete_finding' pk=finding.pk %}" class="delete-finding-link">Delete</a>
{% endif %}
</div>
{% endfor %}
</details>
{% if can_edit %}
<details>
<summary>Truncate series</summary>
<p>
@@ -80,10 +85,12 @@
<div id="truncate-output"></div>
</details>
{% endif %}
{% endwith %}
<div>Author: {{ series.get_author_display }}</div>
{% if can_edit %}
<details>
<summary>Series info</summary>
<div>
@@ -146,6 +153,7 @@
end
">diff</span></span>
{% endif %}
<script>
$(document).ready(function () {
+1
View File
@@ -297,6 +297,7 @@ urlpatterns = [
),
path("structure/create", views.StructureCreate.as_view(), name="structure_create"),
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>/authors", views.SeriesAuthorUpdate.as_view(), name="series_authors"),
path("series/", views.SeriesView.as_view(), name="series_view"),
+6 -3
View File
@@ -121,7 +121,7 @@ from autocomplete import HTMXAutoComplete
from .decorators import (
user_is_author_or_atlas_editor,
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_author_or_atlas_series_checker,
user_is_atlas_marker,
@@ -198,7 +198,7 @@ def case_detail(request, pk):
@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):
series = get_object_or_404(Series, pk=pk)
@@ -208,10 +208,12 @@ def series_thumbnail(request, pk, finding_pk=None):
@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):
series = get_object_or_404(Series, pk=pk)
can_edit = series.check_user_can_edit(request.user)
editing_finding = -1
if finding_pk is not None:
finding = get_object_or_404(SeriesFinding, pk=finding_pk)
@@ -228,6 +230,7 @@ def series_detail(request, pk, finding_pk=None):
"series": series,
"series_finding_form": series_finding_form,
"editing_finding": editing_finding,
"can_edit": can_edit,
},
)
+1 -1
View File
@@ -291,7 +291,7 @@ EMAIL_USE_SSL = True
ADMINS = [("Ross","ross@xkjq.uk")]
CRISPY_ALLOWED_TEMPLATE_PACK = 'bootstrap5'
CRISPY_ALLOWED_TEMPLATE_PACKS = ('bootstrap5',)
CRISPY_TEMPLATE_PACK = 'bootstrap5'
DEBUG_CONTAINER = False