.
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@ def get_exams(request):
|
||||
if request is None:
|
||||
return Exam.objects.none()
|
||||
|
||||
if not request.user.groups.filter(name="anatomy_checker").exists():
|
||||
if not request.user.groups.filter(name="sba_checker").exists():
|
||||
queryset = Exam.objects.filter(author__id=request.user.id)
|
||||
else:
|
||||
queryset = Exam.objects.all()
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ urlpatterns = [
|
||||
),
|
||||
path(
|
||||
"user_answers/delete",
|
||||
views.user_answer_delete_multiple,
|
||||
views.GenericViews.user_answer_delete_multiple,
|
||||
name="user_answer_delete_multiple",
|
||||
),
|
||||
]
|
||||
|
||||
+13
-11
@@ -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)
|
||||
Reference in New Issue
Block a user