Fixes for django 4 (remove is_ajax)

This commit is contained in:
Ross
2022-12-19 10:24:51 +00:00
parent ac0032da52
commit 9fc457c8a5
8 changed files with 24 additions and 23 deletions
+2 -1
View File
@@ -13,7 +13,8 @@ ENV PYTHONUNBUFFERED 1
# python3 python3-dev gcc \
# gfortran musl-dev \
# libffi-dev openssl-dev
RUN apt-get update && apt-get -y install postgresql postgresql-contrib
RUN apt-get update && apt-get -y install postgresql postgresql-contrib git
# install dependencies
RUN pip install --upgrade pip
+4 -4
View File
@@ -634,7 +634,7 @@ def create_body_part(request):
@csrf_exempt
def get_body_part_id(request):
if request.is_ajax():
if request.accepts("application/json")():
body_part_name = request.GET["body_part_name"]
body_part_id = BodyPart.objects.get(name=body_part_name).id
data = {
@@ -660,7 +660,7 @@ def create_examination(request):
@csrf_exempt
def get_examination_id(request):
if request.is_ajax():
if request.accepts("application/json")():
examination_name = request.GET["examination_name"]
examination_id = Examination.objects.get(name=examination_name).id
data = {
@@ -686,7 +686,7 @@ def create_structure(request):
@csrf_exempt
def get_structure_id(request):
if request.is_ajax():
if request.accepts("application/json")():
structure_name = request.GET["structure_name"]
structure_id = Structure.objects.get(name=structure_name).id
data = {
@@ -718,7 +718,7 @@ class AnatomyQuestionView(LoginRequiredMixin, SingleTableMixin, FilterView):
@user_is_author_or_anatomy_checker
def question_save_annotation(request, pk):
if request.is_ajax() and request.method == "POST":
if request.method == "POST":
question = get_object_or_404(AnatomyQuestion, pk=pk)
question.image_annotations = request.POST.get("annotation")
+1 -1
View File
@@ -796,7 +796,7 @@ def atlas_scrap(request, pk):
@csrf_exempt
def get_examination_id(request):
if request.is_ajax():
if request.accepts("application/json")():
examination_name = request.GET["examination_name"]
examination_id = Examination.objects.get(name=examination_name).id
data = {
+3 -3
View File
@@ -590,7 +590,7 @@ def create_examination(request):
@csrf_exempt
def get_examination_id(request):
if request.is_ajax():
if request.accepts("application/json")():
examination_name = request.GET["examination_name"]
examination_id = Examination.objects.get(name=examination_name).id
data = {
@@ -1210,7 +1210,7 @@ class UserAnswerDelete(SuperuserRequiredMixin, DeleteView):
@user_passes_test(lambda u: u.is_superuser)
def user_answer_delete_multiple(request):
if request.is_ajax():
if request.accepts("application/json")():
answer_ids = json.loads(request.POST["answer_ids"])
# We could probably delete them all at once....
@@ -1244,7 +1244,7 @@ def question_review(request, pk):
"""
Return a json representation of the question when the exam is active
"""
if request.is_ajax():
if request.accepts("application/json")():
exam = get_object_or_404(Exam, pk=pk)
if not exam.publish_results:
+4 -4
View File
@@ -281,7 +281,7 @@ def active_exams_unbased(request, cid=None, passcode=None):
@csrf_exempt
def exam_submit(request):
print(request)
if request.is_ajax and request.method == "POST":
if request.method == "POST":
print(request.POST)
exam_type, exam_id = request.POST.get("eid").split("/")
@@ -379,7 +379,7 @@ def feedback_mark_complete(request, pk):
@csrf_exempt
def answer_suggestion_submit(request):
if request.is_ajax and request.method == "POST":
if request.method == "POST":
post_data = json.loads(request.body)
question_type, qid = post_data["qid"].split("/")
answer_string = post_data["answer"]
@@ -411,7 +411,7 @@ def answer_suggestion_submit(request):
@login_required
def answer_submit(request):
if request.is_ajax and request.method == "POST":
if request.method == "POST":
qid = request.POST.get("qid")
question_type = request.POST.get("question_type")
answer_string = request.POST.get("answer")
@@ -442,7 +442,7 @@ def answer_submit(request):
@login_required
def answer_suggestion_confirm(request):
if request.is_ajax and request.method == "POST":
if request.method == "POST":
question_type = request.POST.get("question_type")
aid = request.POST.get("aid")
status = request.POST.get("status")
+5 -5
View File
@@ -449,7 +449,7 @@ def create_abnormality(request):
@csrf_exempt
def get_abnormality_id(request):
if request.is_ajax():
if request.accepts("application/json")():
abnormality_name = request.GET["abnormality_name"]
abnormality_id = Abnormality.objects.get(name=abnormality_name).id
data = {
@@ -475,7 +475,7 @@ def create_examination(request):
@csrf_exempt
def get_examination_id(request):
if request.is_ajax():
if request.accepts("application/json")():
examination_name = request.GET["examination_name"]
examination_id = Examination.objects.get(name=examination_name).id
data = {
@@ -501,7 +501,7 @@ def create_region(request):
@csrf_exempt
def get_region_id(request):
if request.is_ajax():
if request.accepts("application/json")():
region_name = request.GET["region_name"]
region_id = Region.objects.get(name=region_name).id
data = {
@@ -849,7 +849,7 @@ def question_anonymise_dicom(request, pk):
@user_is_author_or_rapid_checker
def question_save_annotation(request, pk):
if request.is_ajax() and request.method == "POST":
if request.method == "POST":
question = get_object_or_404(Rapid, pk=pk)
image_annotations = json.loads(request.POST.get("annotation"))
@@ -877,7 +877,7 @@ class ExamClone(ExamCloneMixin, ExamCreate):
@login_required
def get_question_by_hash(request):
if request.is_ajax() and request.method == "POST":
if request.method == "POST":
hash = request.POST.get("hash")
+5 -3
View File
@@ -1,4 +1,5 @@
Django==3.2.13
#Django==3.2.13
Django==4.1.4
django_debug_toolbar
django_jquery
django_reversion
@@ -16,7 +17,8 @@ pytesseract
opencv-python
pydicom
django-dbbackup
django-hashedfilenamestorage
#django-hashedfilenamestorage
git+https://github.com/allysonbarros/django-hashedfilenamestorage#egg=django-hashedfilenamestorage
djangorestframework
django-tinymce
django-zipview
@@ -31,5 +33,5 @@ rich
bs4
django-htmx
debugpy
django-cookie-consent
git+https://github.com/jazzband/django-cookie-consent#django-cookie-consent
django-crispy-forms
-2
View File
@@ -424,7 +424,6 @@ class UserAnswerDelete(SuperuserRequiredMixin, DeleteView):
# @user_passes_test(lambda u: u.is_superuser)
# def user_answer_delete_multiple(request):
# if request.is_ajax():
# print(request.POST["answer_ids"])
# answer_ids = json.loads(request.POST["answer_ids"])
#
@@ -432,7 +431,6 @@ class UserAnswerDelete(SuperuserRequiredMixin, DeleteView):
# for id in answer_ids:
# CidUserAnswer.objects.get(pk=id).delete()
# return JsonResponse({"status": "success"})
# return JsonResponse({"status": "error"})
GenericViews = GenericViewBase("sbas", Question, CidUserAnswer, Exam)