This commit is contained in:
Ross
2021-05-05 22:50:07 +01:00
parent 0da6edf5be
commit bfb21c0c47
+31 -31
View File
@@ -1006,34 +1006,34 @@ class RapidViewSet(RevisionMixin, viewsets.ModelViewSet):
class ExamDelete(RevisionMixin, AuthorOrCheckerRequiredMixin, DeleteView): class ExamDelete(RevisionMixin, AuthorOrCheckerRequiredMixin, DeleteView):
model = Exam model = Exam
success_url = reverse_lazy("rapids:index") success_url = reverse_lazy("rapids:index")
class AddSuggestedAnswer(LoginRequiredMixin, CreateView): #class AddSuggestedAnswer(LoginRequiredMixin, CreateView):
model = QuestionNote # model = QuestionNote
form_class = QuestionNoteForm # form_class = QuestionNoteForm
#
#fields = ("author", "note_type", "note") # #fields = ("author", "note_type", "note")
#
#
def get_form_kwargs(self): # def get_form_kwargs(self):
kwargs = super(AddQuestionNote, self).get_form_kwargs() # kwargs = super(AddQuestionNote, self).get_form_kwargs()
# update the kwargs for the form init method with yours # # update the kwargs for the form init method with yours
kwargs.update(self.kwargs) # self.kwargs contains all url conf params # kwargs.update(self.kwargs) # self.kwargs contains all url conf params
return kwargs # return kwargs
#
def get_initial(self): # def get_initial(self):
pk = self.kwargs["pk"] # pk = self.kwargs["pk"]
question_type = self.kwargs["question_type"] # question_type = self.kwargs["question_type"]
if question_type == "rapid": # if question_type == "rapid":
question = Rapid # question = Rapid
content_type = ContentType.objects.get(model="rapid") # content_type = ContentType.objects.get(model="rapid")
elif question_type == "anatomy": # elif question_type == "anatomy":
question = AnatomyQuestion # question = AnatomyQuestion
content_type = ContentType.objects.get(model="anatomyquestion") # content_type = ContentType.objects.get(model="anatomyquestion")
elif question_type == "long": # elif question_type == "long":
question = Long # question = Long
content_type = ContentType.objects.get(model="long") # content_type = ContentType.objects.get(model="long")
else: # else:
raise PermissionError() # raise PermissionError()
#
get_object_or_404(question, pk=pk) # get_object_or_404(question, pk=pk)
return { "content_type" : content_type, # return { "content_type" : content_type,
"object_id" : pk } # "object_id" : pk }