From 975c13977ed23e8c0e3a7e878708e810e783663f Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 4 May 2021 21:59:21 +0100 Subject: [PATCH] . --- generic/forms.py | 9 +++++++-- rad/urls.py | 1 + rad/views.py | 15 +++++++++++---- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/generic/forms.py b/generic/forms.py index aa6b2fb1..34eece12 100755 --- a/generic/forms.py +++ b/generic/forms.py @@ -9,7 +9,7 @@ from django.forms import ( from django.forms import inlineformset_factory from generic.models import ( - Examination + Examination, QuestionNote ) from django.contrib.admin.widgets import FilteredSelectMultiple @@ -19,4 +19,9 @@ from django.forms.widgets import RadioSelect, TextInput, Textarea class ExaminationForm(ModelForm): class Meta: model = Examination - fields = ["examination"] \ No newline at end of file + fields = ["examination"] + +class QuestionNoteForm(ModelForm): + class Meta: + model = QuestionNote() + fields = ["question", "author", "note_type", "note"] \ No newline at end of file diff --git a/rad/urls.py b/rad/urls.py index a2821407..cb0fe612 100644 --- a/rad/urls.py +++ b/rad/urls.py @@ -56,6 +56,7 @@ urlpatterns = [ path("exam/submit", views.exam_submit, name="global_exam_answers_submit"), #path('', include('generic.urls')), path("feedback//", views.feedback_create, name="feedback_create"), + path("feedback/", views.AddQuestionNote().as_view(), name="feedback"), path('api/', include(router.urls)), diff --git a/rad/views.py b/rad/views.py index f209fa01..0f67d82b 100644 --- a/rad/views.py +++ b/rad/views.py @@ -41,6 +41,9 @@ from anatomy.views import AnatomyExamViews from rapids.views import RapidExamViews from longs.views import LongExamViews +from generic.forms import QuestionNoteForm +from generic.models import QuestionNote + @login_required def profile(request): @@ -147,10 +150,14 @@ def exam_submit(request): def feedback_create(request, question_type, pk): if question_type == "anatomy": - content_type = ContentType.objects.get(model="AnatomyQuestion") + question = AnatomyQuestion elif question_type == "rapid": - content_type = ContentType.objects.get(model="Rapid") + question = Rapid elif question_type == "long": - content_type = ContentType.objects.get(model="Long") + question = Long - return JsonResponse({"success": False, "error": "Invalid exam type"}) \ No newline at end of file + return JsonResponse({"success": False, "error": "Invalid exam type"}) + +class AddQuestionNote(LoginRequiredMixin, CreateView): + model = QuestionNote + form_class = QuestionNoteForm \ No newline at end of file