diff --git a/generic/views.py b/generic/views.py index fc6adf0a..0243cee7 100644 --- a/generic/views.py +++ b/generic/views.py @@ -1,5 +1,4 @@ -from rad.views import get_question_and_content_type -from rad.views import get_question_and_c_object_or_404, redirect +from django.shortcuts import render, get_object_or_404, redirect from django.contrib.auth.decorators import login_required, user_passes_test from django.views.decorators.csrf import csrf_exempt @@ -42,6 +41,20 @@ import os #from rad.views import get_question_and_content_type +def get_question_and_content_type(question_type): + if question_type == "rapid": + question = Rapid + content_type = ContentType.objects.get(model="rapid") + elif question_type == "anatomy": + question = AnatomyQuestion + content_type = ContentType.objects.get(model="anatomyquestion") + elif question_type == "long": + question = Long + content_type = ContentType.objects.get(model="long") + else: + raise PermissionError() + + return question, content_type # Create your views here. @login_required diff --git a/rad/views.py b/rad/views.py index ac9500f9..c6279c1b 100644 --- a/rad/views.py +++ b/rad/views.py @@ -1,3 +1,4 @@ +from generic.views import get_question_and_content_type from django.core.exceptions import PermissionDenied from django.shortcuts import render, get_object_or_404, redirect from django.views.decorators.csrf import csrf_exempt @@ -185,20 +186,6 @@ def feedback_create(request, question_type, pk): return JsonResponse({"success": False, "error": "Invalid exam type"}) -def get_question_and_content_type(question_type): - if question_type == "rapid": - question = Rapid - content_type = ContentType.objects.get(model="rapid") - elif question_type == "anatomy": - question = AnatomyQuestion - content_type = ContentType.objects.get(model="anatomyquestion") - elif question_type == "long": - question = Long - content_type = ContentType.objects.get(model="long") - else: - raise PermissionError() - - return question, content_type class AddQuestionNote(CreateView):