From 22519fc385ca3ccb5bfeb4f676bd59d5d7bef6f4 Mon Sep 17 00:00:00 2001 From: jpic Date: Wed, 18 Nov 2015 21:32:15 +0100 Subject: [PATCH] Added autocompletes for dossier --- memopol/settings.py | 1 + memopol/urls.py | 1 + requirements.txt | 1 + votes/admin.py | 21 ++------------------- 4 files changed, 5 insertions(+), 19 deletions(-) diff --git a/memopol/settings.py b/memopol/settings.py index b20df0b..ee3c732 100644 --- a/memopol/settings.py +++ b/memopol/settings.py @@ -65,6 +65,7 @@ ORGANIZATION_NAME = os.environ.get('ORGANIZATION', 'Memopol Demo') INSTALLED_APPS = ( # 'django.contrib.admin', + 'autocomplete_light', # Instead of contrib.admin to use Django-Admin-Plus 'django.contrib.admin.apps.SimpleAdminConfig', 'django.contrib.auth', diff --git a/memopol/urls.py b/memopol/urls.py index 433abd3..4f0281b 100644 --- a/memopol/urls.py +++ b/memopol/urls.py @@ -34,5 +34,6 @@ urlpatterns = patterns('', url(r'^legislature/', include('legislature.urls', namespace='legislature')), url(r'^votes/', include('votes.urls', namespace='votes')), url(r'^positions/', include('positions.urls', namespace='positions')), + url(r'^autocomplete/', include('autocomplete_light.urls')), url(r'^admin/', include(admin.site.urls)), ) diff --git a/requirements.txt b/requirements.txt index d9c25d3..7145490 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,3 +22,4 @@ django-extensions django-debug-toolbar redis djangorestframework +django-autocomplete-light diff --git a/votes/admin.py b/votes/admin.py index 05d5b5d..52af5be 100644 --- a/votes/admin.py +++ b/votes/admin.py @@ -1,24 +1,7 @@ # coding: utf-8 - -# This file is part of memopol. -# -# memopol is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of -# the License, or any later version. -# -# memopol is distributed in the hope that it will -# be useful, but WITHOUT ANY WARRANTY; without even the implied -# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU General Affero Public -# License along with django-representatives. -# If not, see . -# -# Copyright (C) 2015 Arnaud Fabre from __future__ import absolute_import +from autocomplete_light import shortcuts as ac from django.contrib import admin from django.core.urlresolvers import reverse @@ -54,13 +37,13 @@ class MemopolDossierAdmin(admin.ModelAdmin): class RecommendationsAdmin(admin.ModelAdmin): - def link_to_proposal(self): return link_to_edit(self, 'proposal') link_to_proposal.allow_tags = True list_display = ('id', 'title', link_to_proposal, 'recommendation','weight') search_fields = ('title', 'recommendation', 'proposal') + form = ac.modelform_factory(Recommendation, exclude=[]) admin.site.register(MemopolDossier, MemopolDossierAdmin) admin.site.register(Recommendation, RecommendationsAdmin) -- GitLab