improve collection overview page
This commit is contained in:
@@ -1,14 +1,16 @@
|
|||||||
{% extends 'atlas/exams.html' %}
|
{% extends 'atlas/exams.html' %}
|
||||||
|
|
||||||
|
{% load partials %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>{{collection.name}}</h2>
|
<h2>{{collection.name}}</h2>
|
||||||
|
|
||||||
{% include 'exam_notes.html' %}
|
{% include 'exam_notes.html' %}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
Exam mode: {{collection.exam_mode}} (Exam open acess: {{collection.exam_open_access}})<br />
|
Exam mode: {{collection.exam_mode}} (open access: {{collection.exam_open_access}})<br />
|
||||||
Publish results: {{collection.publish_results}}<br />
|
{% include "generic/partials/exams/exam_status.html#publish-results" %}
|
||||||
Active: {{collection.active}}<br />
|
{% include "generic/partials/exams/exam_status.html#exam-active" %}
|
||||||
Collection Type: {{collection.get_collection_type_display}}<br />
|
Collection Type: {{collection.get_collection_type_display}}<br />
|
||||||
Self review: {{collection.self_review}}<br />
|
Self review: {{collection.self_review}}<br />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -81,6 +81,16 @@ urlpatterns = [
|
|||||||
name="collection_take_start",
|
name="collection_take_start",
|
||||||
),
|
),
|
||||||
path("collection/<int:pk>/authors", views.CaseCollectionAuthorUpdate.as_view(), name="collection_authors"),
|
path("collection/<int:pk>/authors", views.CaseCollectionAuthorUpdate.as_view(), name="collection_authors"),
|
||||||
|
path(
|
||||||
|
"collection/<int:pk>/toggle_results_published",
|
||||||
|
views.GenericExamViews.exam_toggle_results_published_htmx,
|
||||||
|
name="exam_toggle_results_published",
|
||||||
|
),
|
||||||
|
path(
|
||||||
|
"collection/<int:pk>/toggle_active",
|
||||||
|
views.GenericExamViews.exam_toggle_active_htmx,
|
||||||
|
name="exam_toggle_active",
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"collection/<int:exam_id>/cids",
|
"collection/<int:exam_id>/cids",
|
||||||
views.GenericExamViews.exam_cids,
|
views.GenericExamViews.exam_cids,
|
||||||
|
|||||||
@@ -104,6 +104,15 @@
|
|||||||
|
|
||||||
</select>
|
</select>
|
||||||
</span>
|
</span>
|
||||||
|
<span>
|
||||||
|
Shorts Exams<br />
|
||||||
|
<select id="shorts-exams" multiple="multiple">
|
||||||
|
{% for name, id in shorts_exams %}
|
||||||
|
<option value="{{id}}">{{name}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</span>
|
||||||
<span>
|
<span>
|
||||||
CaseCollection Exams<br />
|
CaseCollection Exams<br />
|
||||||
<select id="casecollection-exams" multiple="multiple">
|
<select id="casecollection-exams" multiple="multiple">
|
||||||
@@ -213,6 +222,7 @@
|
|||||||
sba_exams: JSON.stringify($("#sbas-exams").val()),
|
sba_exams: JSON.stringify($("#sbas-exams").val()),
|
||||||
longs_exams: JSON.stringify($("#longs-exams").val()),
|
longs_exams: JSON.stringify($("#longs-exams").val()),
|
||||||
anatomy_exams: JSON.stringify($("#anatomy-exams").val()),
|
anatomy_exams: JSON.stringify($("#anatomy-exams").val()),
|
||||||
|
shorts_exams: JSON.stringify($("#shorts-exams").val()),
|
||||||
casecollection_exams: JSON.stringify($("#casecollection-exams").val()),
|
casecollection_exams: JSON.stringify($("#casecollection-exams").val()),
|
||||||
cid_groups: JSON.stringify($("#cid-groups").val()),
|
cid_groups: JSON.stringify($("#cid-groups").val()),
|
||||||
delete: false,
|
delete: false,
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
{% load partials %}
|
||||||
|
|
||||||
|
{% partialdef publish-results %}
|
||||||
|
<div id="publish-results-status">
|
||||||
|
Publish results: <span>{{collection.publish_results}}</span>
|
||||||
|
<button
|
||||||
|
hx-post="{% url 'atlas:exam_toggle_results_published' collection.pk %}"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
hx-target="#publish-results-status"
|
||||||
|
class="btn btn-sm btn-outline-primary reduce-opacity"
|
||||||
|
>
|
||||||
|
{% if collection.publish_results %}Unpublish Results{% else %}Publish Results{% endif %}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{% endpartialdef publish-results %}
|
||||||
|
|
||||||
|
|
||||||
|
{% partialdef exam-active %}
|
||||||
|
<div id="exam-active-status">
|
||||||
|
Exam active: <span>{{collection.active}}</span>
|
||||||
|
<button
|
||||||
|
hx-post="{% url 'atlas:exam_toggle_active' collection.pk %}"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
hx-target="#exam-active-status"
|
||||||
|
class="btn btn-sm btn-outline-primary reduce-opacity"
|
||||||
|
>
|
||||||
|
{% if collection.active %}Deactivate Exam{% else %}Activate Exam{% endif %}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{% endpartialdef exam-active %}
|
||||||
@@ -692,6 +692,58 @@ class ExamViews(View, LoginRequiredMixin):
|
|||||||
data = {"status": "error"}
|
data = {"status": "error"}
|
||||||
return JsonResponse(data, status=400)
|
return JsonResponse(data, status=400)
|
||||||
|
|
||||||
|
@method_decorator(login_required)
|
||||||
|
def exam_toggle_results_published_htmx(self, request, pk):
|
||||||
|
if request.method == "POST":
|
||||||
|
if not self.check_user_edit_access(request.user, exam_id=pk):
|
||||||
|
return HttpResponse(
|
||||||
|
format_html(
|
||||||
|
'<div class="alert alert-danger" role="alert">Error toggling results published.</div>'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
exam = get_object_or_404(self.Exam, pk=pk)
|
||||||
|
|
||||||
|
exam.publish_results = not exam.publish_results
|
||||||
|
exam.save()
|
||||||
|
return render(
|
||||||
|
request, "generic/partials/exams/exam_status.html#publish-results", context={
|
||||||
|
"exam": exam,
|
||||||
|
"collection": exam
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
HttpResponse(
|
||||||
|
format_html(
|
||||||
|
'<div class="alert alert-danger" role="alert">Error toggling results published.</div>'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
@method_decorator(login_required)
|
||||||
|
def exam_toggle_active_htmx(self, request, pk):
|
||||||
|
if request.method == "POST":
|
||||||
|
if not self.check_user_edit_access(request.user, exam_id=pk):
|
||||||
|
return HttpResponse(
|
||||||
|
format_html(
|
||||||
|
'<div class="alert alert-danger" role="alert">Error toggling exam active.</div>'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
exam = get_object_or_404(self.Exam, pk=pk)
|
||||||
|
|
||||||
|
exam.active = not exam.active
|
||||||
|
exam.save()
|
||||||
|
return render(
|
||||||
|
request, "generic/partials/exams/exam_status.html#exam-active", context={
|
||||||
|
"exam": exam,
|
||||||
|
"collection": exam
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
HttpResponse(
|
||||||
|
format_html(
|
||||||
|
'<div class="alert alert-danger" role="alert">Error toggling exam active.</div>'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
@method_decorator(login_required)
|
@method_decorator(login_required)
|
||||||
def exam_toggle_results_published(self, request, pk):
|
def exam_toggle_results_published(self, request, pk):
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
|
|||||||
@@ -1388,3 +1388,11 @@ span#user-id {
|
|||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn.reduce-opacity {
|
||||||
|
opacity: 0.3;
|
||||||
|
transition: opacity 0.2s;
|
||||||
|
}
|
||||||
|
.btn.reduce-opacity:hover, .btn.reduce-opacity:focus {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user