Update/refactor search_channel with aliases and proper query. Resolves #1534.

This commit is contained in:
Griatch 2018-01-06 20:12:51 +01:00
parent e3de3fb1dc
commit d2b89b7613
2 changed files with 31 additions and 32 deletions

View file

@ -76,10 +76,14 @@ class ObjectDBManager(TypedObjectManager):
# simplest case - search by dbref
dbref = self.dbref(ostring)
if dbref:
return dbref
try:
return self.get(id=dbref)
except self.model.DoesNotExist:
pass
# not a dbref. Search by name.
cand_restriction = candidates is not None and Q(pk__in=[_GA(obj, "id") for obj in make_iter(candidates)
if obj]) or Q()
cand_restriction = candidates is not None and Q(
pk__in=[_GA(obj, "id") for obj in make_iter(candidates) if obj]) or Q()
if exact:
return self.filter(cand_restriction & Q(db_account__username__iexact=ostring))
else: # fuzzy matching