improve collection overview page
This commit is contained in:
@@ -104,6 +104,15 @@
|
||||
|
||||
</select>
|
||||
</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>
|
||||
CaseCollection Exams<br />
|
||||
<select id="casecollection-exams" multiple="multiple">
|
||||
@@ -213,6 +222,7 @@
|
||||
sba_exams: JSON.stringify($("#sbas-exams").val()),
|
||||
longs_exams: JSON.stringify($("#longs-exams").val()),
|
||||
anatomy_exams: JSON.stringify($("#anatomy-exams").val()),
|
||||
shorts_exams: JSON.stringify($("#shorts-exams").val()),
|
||||
casecollection_exams: JSON.stringify($("#casecollection-exams").val()),
|
||||
cid_groups: JSON.stringify($("#cid-groups").val()),
|
||||
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"}
|
||||
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)
|
||||
def exam_toggle_results_published(self, request, pk):
|
||||
if request.method == "POST":
|
||||
|
||||
Reference in New Issue
Block a user