.
This commit is contained in:
+9
-9
@@ -34,7 +34,7 @@ from .forms import (
|
||||
ExaminationForm,
|
||||
MarkAnatomyQuestionForm,
|
||||
AnatomyQuestionForm,
|
||||
StructureForm,
|
||||
Structure2Form,
|
||||
ExamForm,
|
||||
)
|
||||
from .models import (
|
||||
@@ -42,7 +42,7 @@ from .models import (
|
||||
BodyPart,
|
||||
CidUserAnswer,
|
||||
# Examination,
|
||||
Structure,
|
||||
Structure2,
|
||||
Exam,
|
||||
Answer,
|
||||
# HalfMarkAnswers,
|
||||
@@ -872,7 +872,7 @@ def get_examination_id(request):
|
||||
|
||||
@login_required
|
||||
def create_structure(request):
|
||||
form = StructureForm(request.POST or None)
|
||||
form = Structure2Form(request.POST or None)
|
||||
if form.is_valid():
|
||||
instance = form.save()
|
||||
return HttpResponse(
|
||||
@@ -880,7 +880,7 @@ def create_structure(request):
|
||||
% (instance.pk, instance)
|
||||
)
|
||||
return render(
|
||||
request, "anatomy/create_simple.html", {"form": form, "name": "Structure"}
|
||||
request, "anatomy/create_simple.html", {"form": form, "name": "Structure2"}
|
||||
)
|
||||
|
||||
|
||||
@@ -888,7 +888,7 @@ def create_structure(request):
|
||||
def get_structure_id(request):
|
||||
if request.is_ajax():
|
||||
structure_name = request.GET["structure_name"]
|
||||
structure_id = Structure.objects.get(name=structure_name).id
|
||||
structure_id = Structure2.objects.get(name=structure_name).id
|
||||
data = {
|
||||
"structure_id": structure_id,
|
||||
}
|
||||
@@ -1003,20 +1003,20 @@ class ExamClone(ExamCloneMixin, ExamCreate):
|
||||
"""Clone exam view"""
|
||||
|
||||
|
||||
class StructureAutocomplete(autocomplete.Select2QuerySetView):
|
||||
class Structure2Autocomplete(autocomplete.Select2QuerySetView):
|
||||
def get_queryset(self):
|
||||
# Don't forget to filter out results depending on the visitor !
|
||||
if not self.request.user.is_authenticated:
|
||||
return Structure.objects.none()
|
||||
return Structure2.objects.none()
|
||||
|
||||
qs = Structure.objects.all()
|
||||
qs = Structure2.objects.all()
|
||||
|
||||
if self.q:
|
||||
# This raises a fielderror which breaks creating a new item if not caught
|
||||
try:
|
||||
qs = qs.filter(name__istartswith=self.q)
|
||||
except FieldError:
|
||||
return Structure.objects.none()
|
||||
return Structure2.objects.none()
|
||||
|
||||
|
||||
return qs
|
||||
|
||||
Reference in New Issue
Block a user