Commit 546c0b97 authored by Jamesie Pic's avatar Jamesie Pic
Browse files

Added dossier autocomplete view

parent d97bfd54
...@@ -2,7 +2,20 @@ from dal import autocomplete ...@@ -2,7 +2,20 @@ from dal import autocomplete
from django.db.models import Q from django.db.models import Q
from models import Proposal from models import Dossier, Proposal
class DossierAutocomplete(autocomplete.Select2QuerySetView):
def get_queryset(self):
qs = Dossier.objects.all()
if self.q:
qs = qs.filter(
Q(title__icontains=self.q) |
Q(reference__icontains=self.q)
)
return qs
class ProposalAutocomplete(autocomplete.Select2QuerySetView): class ProposalAutocomplete(autocomplete.Select2QuerySetView):
......
...@@ -17,12 +17,20 @@ urlpatterns = [ ...@@ -17,12 +17,20 @@ urlpatterns = [
] ]
if 'dal_select2' in settings.INSTALLED_APPS: if 'dal_select2' in settings.INSTALLED_APPS:
from autocompletes import ProposalAutocomplete # noqa from autocompletes import ( # noqa
DossierAutocomplete,
ProposalAutocomplete,
)
urlpatterns.append( urlpatterns += [
url(
'^autocomplete/dossier/$',
DossierAutocomplete.as_view(),
name='dossier-autocomplete',
),
url( url(
'autocomplete/proposal/$', 'autocomplete/proposal/$',
ProposalAutocomplete.as_view(), ProposalAutocomplete.as_view(),
name='proposal-autocomplete', name='proposal-autocomplete',
), ),
) ]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment