Fix error in Msg manager search
This commit is contained in:
parent
ebcff51932
commit
b9f0af6413
3 changed files with 15 additions and 10 deletions
|
|
@ -248,25 +248,29 @@ class MsgManager(TypedObjectManager):
|
||||||
# refining with multiple filter:s. Django Note: Q objects can be
|
# refining with multiple filter:s. Django Note: Q objects can be
|
||||||
# combined with & and | (=AND,OR). ~ negates the queryset
|
# combined with & and | (=AND,OR). ~ negates the queryset
|
||||||
|
|
||||||
# filter by sender
|
# filter by sender (we need __pk to avoid an error with empty Q() objects)
|
||||||
sender, styp = identify_object(sender)
|
sender, styp = identify_object(sender)
|
||||||
|
if sender:
|
||||||
|
spk = sender.pk
|
||||||
if styp == "account":
|
if styp == "account":
|
||||||
sender_restrict = Q(db_sender_accounts=sender) & ~Q(db_hide_from_accounts=sender)
|
sender_restrict = Q(db_sender_accounts__pk=spk) & ~Q(db_hide_from_accounts__pk=spk)
|
||||||
elif styp == "object":
|
elif styp == "object":
|
||||||
sender_restrict = Q(db_sender_objects=sender) & ~Q(db_hide_from_objects=sender)
|
sender_restrict = Q(db_sender_objects__pk=spk) & ~Q(db_hide_from_objects__pk=spk)
|
||||||
elif styp == 'script':
|
elif styp == 'script':
|
||||||
sender_restrict = Q(db_sender_scripts=sender)
|
sender_restrict = Q(db_sender_scripts__pk=spk)
|
||||||
else:
|
else:
|
||||||
sender_restrict = Q()
|
sender_restrict = Q()
|
||||||
# filter by receiver
|
# filter by receiver
|
||||||
receiver, rtyp = identify_object(receiver)
|
receiver, rtyp = identify_object(receiver)
|
||||||
|
if receiver:
|
||||||
|
rpk = receiver.pk
|
||||||
if rtyp == "account":
|
if rtyp == "account":
|
||||||
receiver_restrict = (
|
receiver_restrict = (
|
||||||
Q(db_receivers_accounts=receiver) & ~Q(db_hide_from_accounts=receiver ))
|
Q(db_receivers_accounts__pk=rpk) & ~Q(db_hide_from_accounts__pk=rpk))
|
||||||
elif rtyp == "object":
|
elif rtyp == "object":
|
||||||
receiver_restrict = Q(db_receivers_objects=receiver) & ~Q(db_hide_from_objects=receiver)
|
receiver_restrict = Q(db_receivers_objects__pk=rpk) & ~Q(db_hide_from_objects__pk=rpk)
|
||||||
elif rtyp == 'script':
|
elif rtyp == 'script':
|
||||||
receiver_restrict = Q(db_receivers_scripts=receiver)
|
receiver_restrict = Q(db_receivers_scripts__pk=rpk)
|
||||||
elif rtyp == "channel":
|
elif rtyp == "channel":
|
||||||
raise DeprecationWarning(
|
raise DeprecationWarning(
|
||||||
"Msg.objects.search don't accept channel recipients since "
|
"Msg.objects.search don't accept channel recipients since "
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ from evennia.utils.utils import crop
|
||||||
from evennia.utils import validatorfuncs
|
from evennia.utils import validatorfuncs
|
||||||
|
|
||||||
|
|
||||||
class BaseOption(object):
|
class BaseOption:
|
||||||
"""
|
"""
|
||||||
Abstract Class to deal with encapsulating individual Options. An Option has
|
Abstract Class to deal with encapsulating individual Options. An Option has
|
||||||
a name/key, a description to display in relevant commands and menus, and a
|
a name/key, a description to display in relevant commands and menus, and a
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ _GA = object.__getattribute__
|
||||||
_SA = object.__setattr__
|
_SA = object.__setattr__
|
||||||
|
|
||||||
|
|
||||||
class InMemorySaveHandler(object):
|
class InMemorySaveHandler:
|
||||||
"""
|
"""
|
||||||
Fallback SaveHandler, implementing a minimum of the required save mechanism
|
Fallback SaveHandler, implementing a minimum of the required save mechanism
|
||||||
and storing data in memory.
|
and storing data in memory.
|
||||||
|
|
@ -22,7 +22,7 @@ class InMemorySaveHandler(object):
|
||||||
return self.storage.get(key, default)
|
return self.storage.get(key, default)
|
||||||
|
|
||||||
|
|
||||||
class OptionHandler(object):
|
class OptionHandler:
|
||||||
"""
|
"""
|
||||||
This is a generic Option handler. Retrieve options either as properties on
|
This is a generic Option handler. Retrieve options either as properties on
|
||||||
this handler or by using the .get method.
|
this handler or by using the .get method.
|
||||||
|
|
@ -57,6 +57,7 @@ class OptionHandler(object):
|
||||||
A common one to pass would be AttributeHandler.get.
|
A common one to pass would be AttributeHandler.get.
|
||||||
save_kwargs (any): Optional extra kwargs to pass into `savefunc` above.
|
save_kwargs (any): Optional extra kwargs to pass into `savefunc` above.
|
||||||
load_kwargs (any): Optional extra kwargs to pass into `loadfunc` above.
|
load_kwargs (any): Optional extra kwargs to pass into `loadfunc` above.
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
Both loadfunc and savefunc must be specified. If only one is given, the other
|
Both loadfunc and savefunc must be specified. If only one is given, the other
|
||||||
will be ignored and in-memory storage will be used.
|
will be ignored and in-memory storage will be used.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue