Getting rid of functions_help in favor of the new manager. Removed an un-needed import from commands/general.
This commit is contained in:
parent
d620f3b1f0
commit
ccf078b5c8
4 changed files with 37 additions and 39 deletions
|
|
@ -4,5 +4,31 @@ Custom manager for HelpEntry objects.
|
|||
from django.db import models
|
||||
|
||||
class HelpEntryManager(models.Manager):
|
||||
pass
|
||||
def find_topicmatch(self, pobject, topicstr):
|
||||
"""
|
||||
Searches for matching topics based on player's input.
|
||||
"""
|
||||
is_staff = pobject.is_staff()
|
||||
|
||||
if topicstr.isdigit():
|
||||
t_query = self.filter(id=topicstr)
|
||||
else:
|
||||
t_query = self.filter(topicname__istartswith=topicstr)
|
||||
|
||||
if not is_staff:
|
||||
return t_query.exclude(staff_only=1)
|
||||
|
||||
return t_query
|
||||
|
||||
def find_topicsuggestions(self, pobject, topicstr):
|
||||
"""
|
||||
Do a fuzzier "contains" match.
|
||||
"""
|
||||
is_staff = pobject.is_staff()
|
||||
t_query = self.filter(topicname__icontains=topicstr)
|
||||
|
||||
if not is_staff:
|
||||
return t_query.exclude(staff_only=1)
|
||||
|
||||
return t_query
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import time
|
||||
|
||||
import settings
|
||||
from django.conf import settings
|
||||
|
||||
import functions_general
|
||||
import functions_db
|
||||
import functions_help
|
||||
import functions_comsys
|
||||
import defines_global
|
||||
import ansi
|
||||
|
|
|
|||
|
|
@ -1,18 +1,19 @@
|
|||
"""
|
||||
Generic command module. Pretty much every command should go here for
|
||||
now.
|
||||
"""
|
||||
import time
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from apps.config.models import ConfigValue
|
||||
from apps.helpsys.models import HelpEntry
|
||||
import functions_general
|
||||
import functions_db
|
||||
import functions_help
|
||||
import defines_global
|
||||
import session_mgr
|
||||
import ansi
|
||||
"""
|
||||
Generic command module. Pretty much every command should go here for
|
||||
now.
|
||||
"""
|
||||
|
||||
def cmd_password(cdat):
|
||||
"""
|
||||
Changes your own password.
|
||||
|
|
@ -515,11 +516,11 @@ def cmd_help(cdat):
|
|||
session.msg("Your search query is too short. It must be at least three letters long.")
|
||||
return
|
||||
|
||||
topics = functions_help.find_topicmatch(pobject, topicstr)
|
||||
topics = HelpEntry.objects.find_topicmatch(pobject, topicstr)
|
||||
|
||||
if len(topics) == 0:
|
||||
session.msg("No matching topics found, please refine your search.")
|
||||
suggestions = functions_help.find_topicsuggestions(pobject, topicstr)
|
||||
suggestions = HelpEntry.objects.find_topicsuggestions(pobject, topicstr)
|
||||
if len(suggestions) > 0:
|
||||
session.msg("Matching similarly named topics:")
|
||||
for result in suggestions:
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
from apps.helpsys.models import HelpEntry
|
||||
"""
|
||||
Help system functions.
|
||||
"""
|
||||
def find_topicmatch(pobject, topicstr):
|
||||
"""
|
||||
Searches for matching topics based on player's input.
|
||||
"""
|
||||
is_staff = pobject.is_staff()
|
||||
if topicstr.isdigit():
|
||||
if is_staff:
|
||||
return HelpEntry.objects.filter(id=topicstr)
|
||||
else:
|
||||
return HelpEntry.objects.filter(id=topicstr).exclude(staff_only=1)
|
||||
else:
|
||||
if is_staff:
|
||||
return HelpEntry.objects.filter(topicname__istartswith=topicstr)
|
||||
else:
|
||||
return HelpEntry.objects.filter(topicname__istartswith=topicstr).exclude(staff_only=1)
|
||||
|
||||
def find_topicsuggestions(pobject, topicstr):
|
||||
"""
|
||||
Do a fuzzier "contains" match.
|
||||
"""
|
||||
is_staff = pobject.is_staff()
|
||||
if is_staff:
|
||||
return HelpEntry.objects.filter(topicname__icontains=topicstr)
|
||||
else:
|
||||
return HelpEntry.objects.filter(topicname__icontains=topicstr).exclude(staff_only=1)
|
||||
Loading…
Add table
Add a link
Reference in a new issue