try basic autocomplete for authority records

This commit is contained in:
Sanj 2011-08-30 18:58:41 +05:30
parent 052561ebc5
commit ccd8f454f8
6 changed files with 81 additions and 1 deletions

View File

@ -58,6 +58,8 @@ class featuresForm(forms.ModelForm):
url = forms.CharField(label='URI', url = forms.CharField(label='URI',
required=True, required=True,
widget=forms.TextInput(attrs={'size': '40'})) widget=forms.TextInput(attrs={'size': '40'}))
authority_record = AutoCompleteSelectField('authority_record', required=False)
# exclude = ('info',) # exclude = ('info',)
class Meta: class Meta:

View File

@ -84,6 +84,17 @@ MIDDLEWARE_CLASSES = (
'debug_toolbar.middleware.DebugToolbarMiddleware', 'debug_toolbar.middleware.DebugToolbarMiddleware',
) )
AJAX_LOOKUP_CHANNELS = {
# the simplest case, pass a DICT with the model and field to search against :
'authority_record' : dict(model='places.authorityrecord',search_field='preferred_name'),
# this generates a simple channel
# specifying the model Track in the music app, and searching against the 'title' field
# or write a custom search channel and specify that using a TUPLE
# 'contact' : ('peoplez.lookups', 'ContactLookup'),
# this specifies to look for the class `ContactLookup` in the `peoplez.lookups` module
}
ROOT_URLCONF = 'gazetteer.urls' ROOT_URLCONF = 'gazetteer.urls'
TEMPLATE_DIRS = ( TEMPLATE_DIRS = (

View File

@ -0,0 +1,48 @@
.ac_results {
padding: 0px;
border: 1px solid black;
background-color: white;
overflow: hidden;
z-index: 99999;
}
.ac_results ul {
width: 100%;
list-style-position: outside;
list-style: none;
padding: 0;
margin: 0;
}
.ac_results li {
margin: 0px;
padding: 2px 5px;
cursor: default;
display: block;
/*
if width will be 100% horizontal scrollbar will apear
when scroll mode will be used
*/
/*width: 100%;*/
font: menu;
font-size: 12px;
/*
it is very important, if line-height not setted or setted
in relative units scroll will be broken in firefox
*/
line-height: 16px;
overflow: hidden;
}
.ac_loading {
background: white url('indicator.gif') right center no-repeat;
}
.ac_odd {
background-color: #eee;
}
.ac_over {
background-color: #0A246A;
color: white;
}

File diff suppressed because one or more lines are too long

View File

@ -2,8 +2,12 @@
{% block extrahead %} {% block extrahead %}
{{ block.super }} {{ block.super }}
<script type="text/javascript" src="/static/js/jquery.js"></script>
<script type="text/javascript" src="/static/js/jquery.autocomplete.min.js"></script>
<!-- jquery autocomplete from: https://github.com/agarzola/jQueryAutocompletePlugin -->
<script type="text/javascript" src="/static/js/feature_admin.js"></script> <script type="text/javascript" src="/static/js/feature_admin.js"></script>
<link rel="stylesheet" href="/static/css/feature_admin.css" /> <link rel="stylesheet" href="/static/css/feature_admin.css" />
<link rel="stylesheet" href="/static/css/jquery.autocomplete.css" />
{% endblock %} {% endblock %}
{% block after_related_objects %} {% block after_related_objects %}

View File

@ -15,7 +15,7 @@ urlpatterns = patterns('',
('^search_related_json$', 'places.views.search_related_json'), ('^search_related_json$', 'places.views.search_related_json'),
# Uncomment the admin/doc line below to enable admin documentation: # Uncomment the admin/doc line below to enable admin documentation:
(r'^admin/doc/', include('django.contrib.admindocs.urls')), (r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^ajax_select/', include('ajax_select.urls')),
# Uncomment the next line to enable the admin: # Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)), (r'^admin/', include(admin.site.urls)),
) )