Starting here, trunk is broken pending re-organizations. Check out the previous revision if you'd like to tinker.
This commit is contained in:
parent
4b25a08597
commit
837f1152c6
28 changed files with 0 additions and 0 deletions
0
src/helpsys/__init__.py
Normal file
0
src/helpsys/__init__.py
Normal file
1
src/helpsys/fixtures/initial_data.json
Normal file
1
src/helpsys/fixtures/initial_data.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
[{"pk": 3, "model": "helpsys.helpentry", "fields": {"entrytext": "Commands in Evennia are generally organized into one of two categories: %cgPublic%cn or %cyPrivileged%cn commands.\n\n%cgPublic%cn commands are more or less available to everyone. None of these commands are prefixed with anything, they are typical, every-day commands like %chlook%cn, %chsay%cn, and %chget%cn.\n\n%cyPrivileged%cn command availability is largely dependent on the privileges and powers bestowed on you by the staff. Privileged commands are generally building\/administration related and aren't of general interest to players. These commands are all pre-fixed by a '%ch@%cn' character.\n\nTo see a list of all commands, use %ch@list commands%cn. If you'd like to learn more about any individual command, you may do so by typing %chhelp <topic>%cn, where <topic> is the name of the command (without the <>'s).", "topicname": "Commands", "staff_only": false}}, {"pk": 2, "model": "helpsys.helpentry", "fields": {"entrytext": "Evennia is a product of a small community of developers, all working towards the continual improvement of the codebase. The following people have made major contributions with the end result being what you are now playing.\n\n\"Kelvin\" (Greg Taylor) - Lead developer and original author.", "topicname": "Credits", "staff_only": false}}, {"pk": 1, "model": "helpsys.helpentry", "fields": {"entrytext": "This game has yet to customize its help index, so for now you may browse the generic codebase help files.\n\nTopics\nNEWBIE %t%t Getting started (for new players).\nCOMMANDS %t How to get help with commands.\nCREDITS %t Codebase credits.", "topicname": "Help Index", "staff_only": false}}]
|
||||
0
src/helpsys/managers/__init__.py
Normal file
0
src/helpsys/managers/__init__.py
Normal file
34
src/helpsys/managers/helpentry.py
Normal file
34
src/helpsys/managers/helpentry.py
Normal 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
|
||||
|
||||
48
src/helpsys/models.py
Normal file
48
src/helpsys/models.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
"""
|
||||
Models for the help system.
|
||||
"""
|
||||
from django.db import models
|
||||
from django.contrib import admin
|
||||
from src import ansi
|
||||
from apps.helpsys.managers.helpentry import HelpEntryManager
|
||||
|
||||
class HelpEntry(models.Model):
|
||||
"""
|
||||
A generic help entry.
|
||||
"""
|
||||
topicname = models.CharField(max_length=255)
|
||||
entrytext = models.TextField(blank=True, null=True)
|
||||
staff_only = models.BooleanField(default=0)
|
||||
|
||||
objects = HelpEntryManager()
|
||||
|
||||
class Admin:
|
||||
list_display = ('id', 'topicname', 'staff_only')
|
||||
list_filter = ('staff_only',)
|
||||
search_fields = ['entrytext']
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = "Help entries"
|
||||
ordering = ['topicname']
|
||||
|
||||
def __str__(self):
|
||||
return self.topicname
|
||||
|
||||
def get_topicname(self):
|
||||
"""
|
||||
Returns the topic's name.
|
||||
"""
|
||||
try:
|
||||
return self.topicname
|
||||
except:
|
||||
return None
|
||||
|
||||
def get_entrytext_ingame(self):
|
||||
"""
|
||||
Gets the entry text for in-game viewing.
|
||||
"""
|
||||
try:
|
||||
return ansi.parse_ansi(self.entrytext)
|
||||
except:
|
||||
return None
|
||||
admin.site.register(HelpEntry)
|
||||
1
src/helpsys/views.py
Normal file
1
src/helpsys/views.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
# Create your views here.
|
||||
Loading…
Add table
Add a link
Reference in a new issue