.
This commit is contained in:
+5
-4
@@ -25,7 +25,7 @@ from generic.models import Examination
|
|||||||
from django.contrib.admin.widgets import FilteredSelectMultiple
|
from django.contrib.admin.widgets import FilteredSelectMultiple
|
||||||
from django.forms.widgets import RadioSelect, TextInput, Textarea
|
from django.forms.widgets import RadioSelect, TextInput, Textarea
|
||||||
|
|
||||||
import select2.fields
|
from dal import autocomplete
|
||||||
|
|
||||||
class AnatomyAnswerForm(ModelForm):
|
class AnatomyAnswerForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -90,9 +90,10 @@ class AnatomyQuestionForm(ModelForm):
|
|||||||
required=False,
|
required=False,
|
||||||
queryset=Structure.objects.all(),
|
queryset=Structure.objects.all(),
|
||||||
)
|
)
|
||||||
#self.fields["structure"] =select2.fields.ChoiceField(
|
self.fields["structure"] = ModelChoiceField(
|
||||||
#choices=Structure.objects.all(),
|
queryset=Structure.objects.all(),
|
||||||
#overlay="Choose an author...")
|
widget=autocomplete.ModelSelect2(url='anatomy:struture-autocomplete')
|
||||||
|
)
|
||||||
|
|
||||||
self.fields["examination"] = ModelChoiceField(
|
self.fields["examination"] = ModelChoiceField(
|
||||||
required=False,
|
required=False,
|
||||||
|
|||||||
@@ -147,4 +147,9 @@ urlpatterns = [
|
|||||||
views.GenericViews.user_answer_delete_multiple,
|
views.GenericViews.user_answer_delete_multiple,
|
||||||
name="user_answer_delete_multiple",
|
name="user_answer_delete_multiple",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"structure-autocomplete",
|
||||||
|
views.StructureAutocomplete.as_view(),
|
||||||
|
name="structure-autocomplete",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ from django.http import Http404, JsonResponse
|
|||||||
|
|
||||||
from django.http import HttpResponseRedirect, HttpResponse
|
from django.http import HttpResponseRedirect, HttpResponse
|
||||||
|
|
||||||
|
from dal import autocomplete
|
||||||
|
|
||||||
from .forms import (
|
from .forms import (
|
||||||
AnatomyAnswerForm,
|
AnatomyAnswerForm,
|
||||||
AnswerFormSet,
|
AnswerFormSet,
|
||||||
@@ -998,3 +1000,16 @@ GenericViews = GenericViewBase("anatomy", AnatomyQuestion, CidUserAnswer, Exam)
|
|||||||
|
|
||||||
class ExamClone(ExamCloneMixin, ExamCreate):
|
class ExamClone(ExamCloneMixin, ExamCreate):
|
||||||
"""Clone exam view"""
|
"""Clone exam view"""
|
||||||
|
|
||||||
|
class StructureAutocomplete(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()
|
||||||
|
|
||||||
|
qs = Structure.objects.all()
|
||||||
|
|
||||||
|
if self.q:
|
||||||
|
qs = qs.filter(name__istartswith=self.q)
|
||||||
|
|
||||||
|
return qs
|
||||||
+3
-1
@@ -44,6 +44,9 @@ INSTALLED_APPS = [
|
|||||||
"filer",
|
"filer",
|
||||||
"mptt",
|
"mptt",
|
||||||
"sortedm2m",
|
"sortedm2m",
|
||||||
|
"dal",
|
||||||
|
"dal_select2",
|
||||||
|
"dal_queryset_sequence",
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
@@ -55,7 +58,6 @@ INSTALLED_APPS = [
|
|||||||
"dbbackup",
|
"dbbackup",
|
||||||
"rest_framework",
|
"rest_framework",
|
||||||
"tinymce",
|
"tinymce",
|
||||||
"select2",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|||||||
+1
-1
@@ -21,4 +21,4 @@ djangorestframework
|
|||||||
django-tinymce
|
django-tinymce
|
||||||
django-zipview
|
django-zipview
|
||||||
pymemcache
|
pymemcache
|
||||||
django-select2-forms
|
django-autocomplete-light
|
||||||
|
|||||||
Reference in New Issue
Block a user