Fix object-search tag query bypassing search string. Resolve #3438
This commit is contained in:
parent
56ce601bdc
commit
78385d7155
3 changed files with 22 additions and 6 deletions
|
|
@ -24,10 +24,13 @@
|
||||||
will show for admins in some more places (Griatch)
|
will show for admins in some more places (Griatch)
|
||||||
- [Fix][pull3420]: Refactor Clothing contrib's inventory command align with
|
- [Fix][pull3420]: Refactor Clothing contrib's inventory command align with
|
||||||
Evennia core's version (michaelfaith84, Griatch)
|
Evennia core's version (michaelfaith84, Griatch)
|
||||||
|
- [Fix][issue3438]: Limiting search by tag didn't take search-string into
|
||||||
|
account (Griatch)
|
||||||
- Fix: Resolve a bug when loading on-demand-handler data from database (Griatch)
|
- Fix: Resolve a bug when loading on-demand-handler data from database (Griatch)
|
||||||
- Doc fixes (iLPdev, Griatch, CloudKeeper)
|
- Doc fixes (iLPdev, Griatch, CloudKeeper)
|
||||||
|
|
||||||
[pull3420]: https://github.com/evennia/evennia/pull/3420
|
[pull3420]: https://github.com/evennia/evennia/pull/3420
|
||||||
|
[issue3438]: https://github.com/evennia/evennia/issues/3438
|
||||||
|
|
||||||
## Evennia 3.2.0
|
## Evennia 3.2.0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import re
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.db.models.fields import exceptions
|
from django.db.models.fields import exceptions
|
||||||
|
|
||||||
from evennia.server import signals
|
from evennia.server import signals
|
||||||
from evennia.typeclasses.managers import TypeclassManager, TypedObjectManager
|
from evennia.typeclasses.managers import TypeclassManager, TypedObjectManager
|
||||||
from evennia.utils.utils import (
|
from evennia.utils.utils import (
|
||||||
|
|
@ -442,9 +441,6 @@ class ObjectDBManager(TypedObjectManager):
|
||||||
)
|
)
|
||||||
|
|
||||||
def _search_by_tag(query, taglist):
|
def _search_by_tag(query, taglist):
|
||||||
if not query:
|
|
||||||
query = self.all()
|
|
||||||
|
|
||||||
for tagkey, tagcategory in taglist:
|
for tagkey, tagcategory in taglist:
|
||||||
query = query.filter(db_tags__db_key=tagkey, db_tags__db_category=tagcategory)
|
query = query.filter(db_tags__db_key=tagkey, db_tags__db_category=tagcategory)
|
||||||
|
|
||||||
|
|
@ -452,7 +448,7 @@ class ObjectDBManager(TypedObjectManager):
|
||||||
|
|
||||||
if not searchdata and searchdata != 0:
|
if not searchdata and searchdata != 0:
|
||||||
if tags:
|
if tags:
|
||||||
return _search_by_tag(make_iter(tags))
|
return _search_by_tag(self.all(), make_iter(tags))
|
||||||
|
|
||||||
return self.none()
|
return self.none()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ from evennia.typeclasses.tags import (
|
||||||
TagCategoryProperty,
|
TagCategoryProperty,
|
||||||
TagProperty,
|
TagProperty,
|
||||||
)
|
)
|
||||||
from evennia.utils import create
|
from evennia.utils import create, search
|
||||||
from evennia.utils.test_resources import BaseEvenniaTest, EvenniaTestCase
|
from evennia.utils.test_resources import BaseEvenniaTest, EvenniaTestCase
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -137,6 +137,23 @@ class DefaultObjectTest(BaseEvenniaTest):
|
||||||
DefaultObject.get_default_lockstring(account=self.account, caller=self.char1), pattern
|
DefaultObject.get_default_lockstring(account=self.account, caller=self.char1), pattern
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_search_by_tag_kwarg(self):
|
||||||
|
"Test the by_tag method"
|
||||||
|
|
||||||
|
self.obj1.tags.add("plugh", category="adventure")
|
||||||
|
|
||||||
|
self.assertEqual(self.char1.search("Obj", quiet=True), [self.obj1])
|
||||||
|
# should not find a match
|
||||||
|
self.assertEqual(self.char1.search("Dummy", quiet=True), [])
|
||||||
|
# should still not find a match
|
||||||
|
self.assertEqual(self.char1.search("Dummy", tags=[("plugh", "adventure")], quiet=True), [])
|
||||||
|
|
||||||
|
self.assertEqual(list(search.search_object("Dummy", tags=[("plugh", "adventure")])), [])
|
||||||
|
self.assertEqual(
|
||||||
|
list(search.search_object("Obj", tags=[("plugh", "adventure")])), [self.obj1]
|
||||||
|
)
|
||||||
|
self.assertEqual(list(search.search_object("Obj", tags=[("dummy", "adventure")])), [])
|
||||||
|
|
||||||
def test_get_default_lockstring_room(self):
|
def test_get_default_lockstring_room(self):
|
||||||
pattern = (
|
pattern = (
|
||||||
f"control:pid({self.account.id}) or id({self.char1.id}) or"
|
f"control:pid({self.account.id}) or id({self.char1.id}) or"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue