.
This commit is contained in:
+29
-1
@@ -15,6 +15,11 @@ from generic.models import (
|
||||
from django.contrib.admin.widgets import FilteredSelectMultiple
|
||||
from django.forms.widgets import RadioSelect, TextInput, Textarea
|
||||
|
||||
from rapids.models import Rapid
|
||||
from anatomy.models import AnatomyQuestion
|
||||
from longs.models import Long
|
||||
|
||||
from django.shortcuts import render, get_object_or_404, redirect
|
||||
|
||||
class ExaminationForm(ModelForm):
|
||||
class Meta:
|
||||
@@ -24,4 +29,27 @@ class ExaminationForm(ModelForm):
|
||||
class QuestionNoteForm(ModelForm):
|
||||
class Meta:
|
||||
model = QuestionNote
|
||||
fields = ["content_type", "object_id", "author", "note_type", "note"]
|
||||
fields = ["content_type", "object_id", "author", "note_type", "note"]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
question_type = kwargs.pop("question_type")
|
||||
|
||||
if question_type == "rapid":
|
||||
question = Rapid
|
||||
elif question_type == "anatomy":
|
||||
question = AnatomyQuestion
|
||||
elif question_type == "long":
|
||||
question = AnatomyQuestion
|
||||
else:
|
||||
raise PermissionError()
|
||||
|
||||
get_object_or_404(question, pk=kwargs.pop("pk"))
|
||||
# We get the 'initial' keyword argument or initialize it
|
||||
# as a dict if it didn't exist.
|
||||
initial = kwargs.setdefault("initial", {})
|
||||
# The widget for a ModelMultipleChoiceField expects
|
||||
# a list of primary key for the selected data.
|
||||
#initial["content_type"] = [t.pk for t in kwargs["instance"].exams.all()]
|
||||
|
||||
ModelForm.__init__(self, *args, **kwargs)
|
||||
#super(QuestionNoteForm(), self).__init__(*args, **kwargs)
|
||||
Reference in New Issue
Block a user