From 09d9c42a59d4192394fdec1e23812943ca2e5c74 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 27 Jun 2022 22:12:51 +0100 Subject: [PATCH] . --- .../atlas/collection_case_view_take.html | 2 +- atlas/views.py | 43 ++++++++++--------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/atlas/templates/atlas/collection_case_view_take.html b/atlas/templates/atlas/collection_case_view_take.html index bce8f741..1f0134f1 100644 --- a/atlas/templates/atlas/collection_case_view_take.html +++ b/atlas/templates/atlas/collection_case_view_take.html @@ -78,7 +78,7 @@ {% endif %}

{% endif %} - {% if previous > -1 %} + {% if previous %} {% endif %} {% if next %} diff --git a/atlas/views.py b/atlas/views.py index 0d75b619..291055c5 100755 --- a/atlas/views.py +++ b/atlas/views.py @@ -1256,31 +1256,33 @@ def collection_case_view_take(request, pk, case_number, cid, passcode): cases = collection.cases.all().order_by("casedetail__sort_order").prefetch_related() case = cases[case_number] - c = CidUser.objects.filter(cid=cid).first() - cid_user_exam = collection.get_or_create_cid_user_exam(cid_user=c) - case_detail = CaseDetail.objects.get(case=case, collection=collection) - answer = case_detail.cidreportanswer_set.filter(cid=cid).first() + if collection.collection_type == "REP": + c = CidUser.objects.filter(cid=cid).first() + cid_user_exam = collection.get_or_create_cid_user_exam(cid_user=c) + case_detail = CaseDetail.objects.get(case=case, collection=collection) + answer = case_detail.cidreportanswer_set.filter(cid=cid).first() if request.method == "POST": - if not collection.publish_results: - if answer: - form = CidReportAnswerForm(request.POST, instance=answer) - else: - form = CidReportAnswerForm(request.POST) - if form.is_valid(): - answer = form.save(commit=False) - answer.cid = cid - answer.question = case_detail - # answer.published_date = timezone.now() - answer.save() + if collection.collection_type == "REP": + if not collection.publish_results: + if answer: + form = CidReportAnswerForm(request.POST, instance=answer) + else: + form = CidReportAnswerForm(request.POST) + if form.is_valid(): + answer = form.save(commit=False) + answer.cid = cid + answer.question = case_detail + # answer.published_date = timezone.now() + answer.save() - cid_user_exam.end_time = timezone.now() - cid_user_exam.save() + cid_user_exam.end_time = timezone.now() + cid_user_exam.save() - kwargs = {"pk": pk, "cid": cid, "passcode": passcode} - redirect_url = "atlas:collection_case_view_take" + kwargs = {"pk": pk, "cid": cid, "passcode": passcode} + redirect_url = "atlas:collection_case_view_take" - if cid is None: + else: kwargs = {"pk": pk} redirect_url = "atlas:collection_case_view_review" @@ -1305,6 +1307,7 @@ def collection_case_view_take(request, pk, case_number, cid, passcode): series_list = case.series.all().prefetch_related("images", "examination", "plane") + print("case_no") previous = case_number > 0 next = case_number < (len(cases) - 1)