Support searching documents by entities
This commit is contained in:
parent
738a9282b4
commit
9a4c24cdb4
2 changed files with 16 additions and 17 deletions
|
|
@ -5,6 +5,9 @@ from django.db.models import Q, Manager
|
|||
import ox
|
||||
from oxdjango.query import QuerySet
|
||||
|
||||
import entity.managers
|
||||
|
||||
|
||||
def parseCondition(condition, user, item=None):
|
||||
'''
|
||||
'''
|
||||
|
|
@ -37,6 +40,9 @@ def buildCondition(k, op, v):
|
|||
return Q(**{k: v})
|
||||
if isinstance(v, bool): #featured and public flag
|
||||
key = k
|
||||
elif k == 'entity':
|
||||
entity_key, v = entity.managers.namePredicate(op, v)
|
||||
key = 'entities__' + entity_key
|
||||
else:
|
||||
key = "%s%s" % (k, {
|
||||
'==': '__iexact',
|
||||
|
|
@ -124,4 +130,3 @@ class DocumentManager(Manager):
|
|||
qs = qs.filter(conditions)
|
||||
|
||||
return qs
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue