This commit is contained in:
Ross
2021-09-30 20:24:50 +01:00
parent 5e6a48480f
commit fd99f51d97
8 changed files with 235 additions and 18 deletions
+13 -11
View File
@@ -37,7 +37,7 @@ import json
import statistics
import plotly.express as px
from generic.views import ExamViews
from generic.views import ExamViews, GenericViewBase
from rest_framework import viewsets, permissions
from rest_framework.pagination import PageNumberPagination
@@ -387,15 +387,17 @@ class UserAnswerDelete(SuperuserRequiredMixin, DeleteView):
template_name = "user_answer_delete.html"
success_url = reverse_lazy("sbas:user_answer_table_view")
@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"])
#@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"])
#
# # We could probably delete them all at once....
# for id in answer_ids:
# CidUserAnswer.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:
CidUserAnswer.objects.get(pk=id).delete()
return JsonResponse({"status": "success"})
return JsonResponse({"status": "error"})
GenericViews = GenericViewBase("sbas", Question, CidUserAnswer, Exam)