From 250d59cc9bea6272b16d56fad9c7fcb6a022dc80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 17 May 2016 22:04:23 +0200 Subject: [PATCH] add autocomplete to plone popup --- .../templates/thesaurus/plone_popup.html | 26 ++++++++++++++++++- .../templates/thesaurus/term_list.html | 6 +++++ pfwb_thesaurus/views.py | 5 ++-- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/pfwb_thesaurus/templates/thesaurus/plone_popup.html b/pfwb_thesaurus/templates/thesaurus/plone_popup.html index 84b4a5b..5676a61 100644 --- a/pfwb_thesaurus/templates/thesaurus/plone_popup.html +++ b/pfwb_thesaurus/templates/thesaurus/plone_popup.html @@ -4,10 +4,11 @@ diff --git a/pfwb_thesaurus/templates/thesaurus/term_list.html b/pfwb_thesaurus/templates/thesaurus/term_list.html index b9077db..004a300 100644 --- a/pfwb_thesaurus/templates/thesaurus/term_list.html +++ b/pfwb_thesaurus/templates/thesaurus/term_list.html @@ -1,6 +1,12 @@ {% extends "base.html" %} {% block content %} + +

Points d'entrée

diff --git a/pfwb_thesaurus/views.py b/pfwb_thesaurus/views.py index 318e248..d6c3592 100644 --- a/pfwb_thesaurus/views.py +++ b/pfwb_thesaurus/views.py @@ -17,6 +17,7 @@ import json from django.conf import settings +from django.core.urlresolvers import reverse from django.http import HttpResponse from django.views.generic import DetailView, ListView @@ -54,8 +55,8 @@ def term_search_json(request): sqs.load_all() result = [] - for item in sqs: - result.append({'title': item.term, 'id': item.id}) + for item in sqs[:15]: + result.append({'title': item.term, 'url': reverse('term', kwargs={'pk': item.pk}), 'id': item.pk}) response = HttpResponse(content_type='application/json') json.dump({'data': result}, response, indent=2)