Starting here, trunk is broken pending re-organizations. Check out the previous revision if you'd like to tinker.

This commit is contained in:
Greg Taylor 2008-12-15 04:00:25 +00:00
parent 4b25a08597
commit 837f1152c6
28 changed files with 0 additions and 0 deletions

View file

View file

@ -0,0 +1,34 @@
"""
Custom manager for HelpEntry objects.
"""
from django.db import models
class HelpEntryManager(models.Manager):
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