Source code for experimentdb.data.lookups
"""This is a configuration file for the ajax lookups for the data app.
See http://code.google.com/p/django-ajax-selects/ for information about configuring the ajax lookups.
"""
from experimentdb.data.models import Protocol
from django.db.models import Q
[docs]class ProtocolLookup(object):
"""This is the generic lookup for protocols.
It is to be used for all protocol requests and directs to the 'protocol' channel.
"""
[docs] def get_query(self,q,request):
""" This sets up the query for the lookup.
The lookup searches the name of the protocol."""
return Protocol.objects.filter(protocol__icontains=q)
[docs] def get_objects(self,ids):
""" given a list of ids, return the objects ordered as you would like them on the admin page.
this is for displaying the currently selected items (in the case of a ManyToMany field)
"""
return Protocol.objects.filter(pk__in=ids)