Switch /contains to default, add /startswith switch instead.
This commit is contained in:
parent
32ea0075e6
commit
bde11edaf0
2 changed files with 14 additions and 14 deletions
|
|
@ -2275,7 +2275,7 @@ class CmdFind(COMMAND_DEFAULT_CLASS):
|
||||||
char - only look for characters (BASE_CHARACTER_TYPECLASS)
|
char - only look for characters (BASE_CHARACTER_TYPECLASS)
|
||||||
exact - only exact matches are returned.
|
exact - only exact matches are returned.
|
||||||
loc - display object location if exists and match has one result
|
loc - display object location if exists and match has one result
|
||||||
contains- search for names containing the string, rather than starting with.
|
startswith - search for names starting with the string, rather than containing
|
||||||
|
|
||||||
Searches the database for an object of a particular name or exact #dbref.
|
Searches the database for an object of a particular name or exact #dbref.
|
||||||
Use *accountname to search for an account. The switches allows for
|
Use *accountname to search for an account. The switches allows for
|
||||||
|
|
@ -2286,7 +2286,7 @@ class CmdFind(COMMAND_DEFAULT_CLASS):
|
||||||
|
|
||||||
key = "@find"
|
key = "@find"
|
||||||
aliases = "@search, @locate"
|
aliases = "@search, @locate"
|
||||||
switch_options = ("room", "exit", "char", "exact", "loc", "contains")
|
switch_options = ("room", "exit", "char", "exact", "loc", "startswith")
|
||||||
locks = "cmd:perm(find) or perm(Builder)"
|
locks = "cmd:perm(find) or perm(Builder)"
|
||||||
help_category = "Building"
|
help_category = "Building"
|
||||||
|
|
||||||
|
|
@ -2360,14 +2360,14 @@ class CmdFind(COMMAND_DEFAULT_CLASS):
|
||||||
keyquery = Q(db_key__iexact=searchstring, id__gte=low, id__lte=high)
|
keyquery = Q(db_key__iexact=searchstring, id__gte=low, id__lte=high)
|
||||||
aliasquery = Q(db_tags__db_key__iexact=searchstring,
|
aliasquery = Q(db_tags__db_key__iexact=searchstring,
|
||||||
db_tags__db_tagtype__iexact="alias", id__gte=low, id__lte=high)
|
db_tags__db_tagtype__iexact="alias", id__gte=low, id__lte=high)
|
||||||
elif "contains" in switches:
|
elif "startswith" in switches:
|
||||||
keyquery = Q(db_key__icontains=searchstring, id__gte=low, id__lte=high)
|
|
||||||
aliasquery = Q(db_tags__db_key__icontains=searchstring,
|
|
||||||
db_tags__db_tagtype__iexact="alias", id__gte=low, id__lte=high)
|
|
||||||
else:
|
|
||||||
keyquery = Q(db_key__istartswith=searchstring, id__gte=low, id__lte=high)
|
keyquery = Q(db_key__istartswith=searchstring, id__gte=low, id__lte=high)
|
||||||
aliasquery = Q(db_tags__db_key__istartswith=searchstring,
|
aliasquery = Q(db_tags__db_key__istartswith=searchstring,
|
||||||
db_tags__db_tagtype__iexact="alias", id__gte=low, id__lte=high)
|
db_tags__db_tagtype__iexact="alias", id__gte=low, id__lte=high)
|
||||||
|
else:
|
||||||
|
keyquery = Q(db_key__icontains=searchstring, id__gte=low, id__lte=high)
|
||||||
|
aliasquery = Q(db_tags__db_key__icontains=searchstring,
|
||||||
|
db_tags__db_tagtype__iexact="alias", id__gte=low, id__lte=high)
|
||||||
|
|
||||||
results = ObjectDB.objects.filter(keyquery | aliasquery).distinct()
|
results = ObjectDB.objects.filter(keyquery | aliasquery).distinct()
|
||||||
nresults = results.count()
|
nresults = results.count()
|
||||||
|
|
|
||||||
|
|
@ -329,7 +329,7 @@ class TestBuilding(CommandTest):
|
||||||
self.call(building.CmdLock(), "Obj = test:perm(Developer)", "Added lock 'test:perm(Developer)' to Obj.")
|
self.call(building.CmdLock(), "Obj = test:perm(Developer)", "Added lock 'test:perm(Developer)' to Obj.")
|
||||||
|
|
||||||
def test_find(self):
|
def test_find(self):
|
||||||
self.call(building.CmdFind(), "Room2", "One Match")
|
self.call(building.CmdFind(), "oom2", "One Match")
|
||||||
expect = "One Match(#1#7, loc):\n " +\
|
expect = "One Match(#1#7, loc):\n " +\
|
||||||
"Char2(#7) evennia.objects.objects.DefaultCharacter (location: Room(#1))"
|
"Char2(#7) evennia.objects.objects.DefaultCharacter (location: Room(#1))"
|
||||||
self.call(building.CmdFind(), "Char2", expect, cmdstring="locate")
|
self.call(building.CmdFind(), "Char2", expect, cmdstring="locate")
|
||||||
|
|
@ -339,7 +339,7 @@ class TestBuilding(CommandTest):
|
||||||
self.call(building.CmdFind(), "Char2", expect, cmdstring="@locate")
|
self.call(building.CmdFind(), "Char2", expect, cmdstring="@locate")
|
||||||
self.call(building.CmdFind(), "/l Char2", expect, cmdstring="find") # /l switch is abbreviated form of /loc
|
self.call(building.CmdFind(), "/l Char2", expect, cmdstring="find") # /l switch is abbreviated form of /loc
|
||||||
self.call(building.CmdFind(), "Char2", "One Match", cmdstring="@find")
|
self.call(building.CmdFind(), "Char2", "One Match", cmdstring="@find")
|
||||||
self.call(building.CmdFind(), "/contains om2", "One Match")
|
self.call(building.CmdFind(), "/startswith Room2", "One Match")
|
||||||
|
|
||||||
def test_script(self):
|
def test_script(self):
|
||||||
self.call(building.CmdScript(), "Obj = scripts.Script", "Script scripts.Script successfully added")
|
self.call(building.CmdScript(), "Obj = scripts.Script", "Script scripts.Script successfully added")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue