Source code for experimentdb.proteins.lookups
"""This is a configuration file for the ajax lookups for the proteins app.
See http://code.google.com/p/django-ajax-selects/ for information about configuring the ajax lookups.
"""
from experimentdb.proteins.models import Protein
from django.db.models import Q
[docs]class ProteinLookup(object):
"""This is the generic lookup for antibodies.
It is to be used for all protein requests and directs to the 'protein' channel.
"""
[docs] def get_query(self,q,request):
""" This sets up the query for the lookup.
The lookup searches the name of the protein."""
return Protein.objects.filter(name__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 Protein.objects.filter(pk__in=ids)