Start django 4 upgrade (and fix adding groups)
This commit is contained in:
+23
-27
@@ -164,7 +164,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 = {
|
||||
@@ -177,7 +177,7 @@ def get_examination_id(request):
|
||||
# Generic view to dispatch to indivuals app views
|
||||
@login_required
|
||||
def generic_exam_json_edit(request):
|
||||
if request.is_ajax() and request.method == "POST":
|
||||
if request.method == "POST":
|
||||
question_type = request.POST.get("type")
|
||||
|
||||
if question_type == "rapid":
|
||||
@@ -468,7 +468,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
@method_decorator(login_required)
|
||||
def exam_toggle_archived(self, request, pk):
|
||||
print("TOGGLE ARCHIVED", request.POST)
|
||||
if request.is_ajax() and request.method == "POST":
|
||||
if request.method == "POST":
|
||||
|
||||
if not self.check_user_edit_access(request.user):
|
||||
data = {"status": "error, insufficient permission"}
|
||||
@@ -494,7 +494,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
|
||||
@method_decorator(login_required)
|
||||
def exam_toggle_results_published(self, request, pk):
|
||||
if request.is_ajax() and request.method == "POST":
|
||||
if request.method == "POST":
|
||||
|
||||
if not self.check_user_edit_access(request.user):
|
||||
data = {"status": "error, insufficient permission"}
|
||||
@@ -519,7 +519,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
|
||||
@method_decorator(login_required)
|
||||
def exam_toggle_active(self, request, pk):
|
||||
if request.is_ajax() and request.method == "POST":
|
||||
if request.method == "POST":
|
||||
|
||||
if not self.check_user_edit_access(request.user):
|
||||
data = {"status": "error, insufficient permission"}
|
||||
@@ -982,7 +982,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
|
||||
@method_decorator(login_required)
|
||||
def exam_json_edit(self, request, pk):
|
||||
if request.is_ajax() and request.method == "POST":
|
||||
if request.method == "POST":
|
||||
|
||||
|
||||
if request.user.groups.filter(name="cid_user_manager").exists():
|
||||
@@ -1311,7 +1311,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
|
||||
@method_decorator(csrf_exempt)
|
||||
def postExamAnswers(self, request):
|
||||
if request.is_ajax and request.method == "POST":
|
||||
if request.method == "POST":
|
||||
|
||||
n = 0
|
||||
|
||||
@@ -1910,32 +1910,28 @@ class GenericViewBase:
|
||||
"""
|
||||
Return a json representation of the question when the exam is published
|
||||
"""
|
||||
if request.is_ajax():
|
||||
exam = get_object_or_404(self.exam_object, pk=pk)
|
||||
exam = get_object_or_404(self.exam_object, pk=pk)
|
||||
|
||||
print(request.POST["question_number"])
|
||||
print(type(request.POST["question_number"]))
|
||||
print(request.POST["question_number"])
|
||||
print(type(request.POST["question_number"]))
|
||||
|
||||
if not exam.publish_results:
|
||||
raise Http404
|
||||
if not exam.publish_results:
|
||||
raise Http404
|
||||
|
||||
question = exam.exam_questions.all()[int(request.POST["question_number"])]
|
||||
question = exam.exam_questions.all()[int(request.POST["question_number"])]
|
||||
|
||||
question_json = question.get_question_json(based=False, feedback=True)
|
||||
return JsonResponse(question_json)
|
||||
return JsonResponse({"status": "error"})
|
||||
question_json = question.get_question_json(based=False, feedback=True)
|
||||
return JsonResponse(question_json)
|
||||
|
||||
@method_decorator(user_passes_test(lambda u: u.is_superuser))
|
||||
def user_answer_delete_multiple(self, request):
|
||||
if request.is_ajax():
|
||||
print(request.POST["answer_ids"])
|
||||
answer_ids = json.loads(request.POST["answer_ids"])
|
||||
print(request.POST["answer_ids"])
|
||||
answer_ids = json.loads(request.POST["answer_ids"])
|
||||
|
||||
# We could probably delete them all at once....
|
||||
for id in answer_ids:
|
||||
self.cid_user_answer_object.objects.get(pk=id).delete()
|
||||
return JsonResponse({"status": "success"})
|
||||
return JsonResponse({"status": "error"})
|
||||
# We could probably delete them all at once....
|
||||
for id in answer_ids:
|
||||
self.cid_user_answer_object.objects.get(pk=id).delete()
|
||||
return JsonResponse({"status": "success"})
|
||||
|
||||
@method_decorator(login_required)
|
||||
def question_detail(self, request, pk):
|
||||
@@ -2266,7 +2262,7 @@ def create_cid_email(request):
|
||||
|
||||
@user_is_cid_user_manager
|
||||
def manage_cid_users(request):
|
||||
if request.is_ajax() and request.method == "POST":
|
||||
if request.method == "POST":
|
||||
physics_exams = json.loads(request.POST.get("physics_exams"))
|
||||
rapid_exams = json.loads(request.POST.get("rapid_exams"))
|
||||
sba_exams = json.loads(request.POST.get("sba_exams"))
|
||||
@@ -2294,7 +2290,7 @@ def manage_cid_users(request):
|
||||
if add_group == "true":
|
||||
cids = CidUser.objects.filter(pk__in=selected_cids)
|
||||
for c in cids:
|
||||
c.group_id = cid_groups[0]
|
||||
c.group_id = cid_groups
|
||||
c.save()
|
||||
return JsonResponse({"status": "success"})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user