Fix HelpEntry model search field in the admin to search for topic name and the topic's text. Add missing search types to @search, aside from 'powers', which will need to be added once we figure out how powers will work.
This commit is contained in:
parent
7280eaf803
commit
16e494f508
2 changed files with 27 additions and 4 deletions
|
|
@ -104,10 +104,33 @@ def build_query(session, search_query, search_player, search_type,
|
|||
elif search_restriction == "player":
|
||||
search_query = search_query.filter(type=defines_global.OTYPE_PLAYER)
|
||||
else:
|
||||
session.msg("Invalid class. Must be one of: room, thing, exit, player")
|
||||
session.msg("Invalid class. See 'help SEARCH CLASSES'.")
|
||||
return None
|
||||
elif search_type == "object":
|
||||
search_query = search_query.filter(name__icontains=search_restriction)
|
||||
elif search_type == "parent":
|
||||
search_query = search_query.filter(script_parent__iexact=search_restriction)
|
||||
elif search_type == "object" or search_type == "thing":
|
||||
search_query = search_query.filter(name__icontains=search_restriction,
|
||||
type=defines_global.OTYPE_THING)
|
||||
elif search_type == "rooms":
|
||||
search_query = search_query.filter(name__icontains=search_restriction,
|
||||
type=defines_global.OTYPE_ROOM)
|
||||
elif search_type == "exits":
|
||||
search_query = search_query.filter(name__icontains=search_restriction,
|
||||
type=defines_global.OTYPE_EXIT)
|
||||
elif search_type == "players":
|
||||
search_query = search_query.filter(name__icontains=search_restriction,
|
||||
type=defines_global.OTYPE_PLAYER)
|
||||
elif search_type == "zone":
|
||||
zone_obj = Object.objects.standard_plr_objsearch(session,
|
||||
search_restriction)
|
||||
# Use standard_plr_objsearch to handle duplicate/nonexistant results.
|
||||
if not zone_obj:
|
||||
return None
|
||||
search_query = search_query.filter(zone=zone_obj)
|
||||
elif search_type == "power":
|
||||
# TODO: Need this once we have powers implemented.
|
||||
session.msg("To be implemented...")
|
||||
return None
|
||||
elif search_type == "flags":
|
||||
flag_list = search_restriction.split()
|
||||
#session.msg("restriction: %s" % flag_list)
|
||||
|
|
|
|||
|
|
@ -39,5 +39,5 @@ class HelpEntryAdmin(admin.ModelAdmin):
|
|||
list_display = ('id', 'topicname', 'staff_only')
|
||||
list_display_links = ('id', 'topicname')
|
||||
list_filter = ('staff_only',)
|
||||
search_fields = ['entrytext']
|
||||
search_fields = ['topicname', 'entrytext']
|
||||
admin.site.register(HelpEntry, HelpEntryAdmin)
|
||||
Loading…
Add table
Add a link
Reference in a new issue