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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue