.
This commit is contained in:
+6
-1
@@ -1,6 +1,6 @@
|
|||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
|
||||||
from atlas.models import Condition, Finding, Structure
|
from atlas.models import Condition, Finding, Presentation, Structure
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
app_name = "atlas"
|
app_name = "atlas"
|
||||||
@@ -123,6 +123,11 @@ urlpatterns = [
|
|||||||
views.ConditionAutocomplete.as_view(model=Condition, create_field="name"),
|
views.ConditionAutocomplete.as_view(model=Condition, create_field="name"),
|
||||||
name="condition-autocomplete",
|
name="condition-autocomplete",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"presentation-autocomplete",
|
||||||
|
views.PresentationAutocomplete.as_view(model=Presentation, create_field="name"),
|
||||||
|
name="presentation-autocomplete",
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"finding-autocomplete",
|
"finding-autocomplete",
|
||||||
views.FindingAutocomplete.as_view(model=Finding, create_field="name"),
|
views.FindingAutocomplete.as_view(model=Finding, create_field="name"),
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ from .forms import (
|
|||||||
from .models import (
|
from .models import (
|
||||||
Case,
|
Case,
|
||||||
Condition,
|
Condition,
|
||||||
|
Presentation,
|
||||||
Series,
|
Series,
|
||||||
Examination,
|
Examination,
|
||||||
Finding,
|
Finding,
|
||||||
@@ -740,6 +741,23 @@ class ConditionAutocomplete(autocomplete.Select2QuerySetView):
|
|||||||
|
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
class PresentationAutocomplete(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 Presentation.objects.none()
|
||||||
|
|
||||||
|
qs = Presentation.objects.all()
|
||||||
|
|
||||||
|
if self.q:
|
||||||
|
# This raises a fielderror which breaks creating a new item if not caught
|
||||||
|
try:
|
||||||
|
qs = qs.filter(name__icontains=self.q)
|
||||||
|
except FieldError:
|
||||||
|
return Presentation.objects.none()
|
||||||
|
|
||||||
|
return qs
|
||||||
|
|
||||||
|
|
||||||
class FindingAutocomplete(autocomplete.Select2QuerySetView):
|
class FindingAutocomplete(autocomplete.Select2QuerySetView):
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user