Indentation change 3-4 spaces.

Possible files that need to be cleanedup;
commands/info.py:cmd_list
commands/general.py:cmd_who
commands/comsys.py:cmd_who

cmdtable.py
ansi.py
This commit is contained in:
loki77 2008-06-13 19:52:29 +00:00
parent 740d715c72
commit 3fe644ef17
31 changed files with 1856 additions and 1856 deletions

View file

@ -1,26 +1,26 @@
from django.db import models
class CommandAlias(models.Model):
"""
Command aliases. If the player enters the value equal to user_input, the
command denoted by equiv_command is used instead.
"""
user_input = models.CharField(max_length=50)
equiv_command = models.CharField(max_length=50)
class Admin:
list_display = ('user_input', 'equiv_command',)
class Meta:
verbose_name_plural = "Command aliases"
ordering = ['user_input']
"""
Command aliases. If the player enters the value equal to user_input, the
command denoted by equiv_command is used instead.
"""
user_input = models.CharField(max_length=50)
equiv_command = models.CharField(max_length=50)
class Admin:
list_display = ('user_input', 'equiv_command',)
class Meta:
verbose_name_plural = "Command aliases"
ordering = ['user_input']
class ConfigValue(models.Model):
"""
Experimental new config model.
"""
conf_key = models.CharField(max_length=100)
conf_value = models.TextField()
class Admin:
list_display = ('conf_key', 'conf_value',)
"""
Experimental new config model.
"""
conf_key = models.CharField(max_length=100)
conf_value = models.TextField()
class Admin:
list_display = ('conf_key', 'conf_value',)

View file

@ -1,23 +1,23 @@
from django.db import models
class GenericPerm(models.Model):
"""
This is merely a container class for some generic permissions that don't
fit under a particular module.
"""
class Meta:
permissions = (
("announce", "May use @wall to make announcements"),
("boot", "May use @boot to kick players"),
("builder", "Can build and modify objects"),
("chown_all", "Can @chown anything to anyone."),
("free_money", "Has infinite money"),
("long_fingers", "May get/look/examine etc. from a distance"),
("steal", "May give negative money"),
("set_hide", "May set themself invisible"),
("tel_anywhere", "May @teleport anywhere"),
("tel_anyone", "May @teleport anything"),
("see_session_data", "May see detailed player session data"),
("process_control", "May shutdown/restart/reload the game"),
("manage_players", "Can change passwords, siteban, etc."),
)
"""
This is merely a container class for some generic permissions that don't
fit under a particular module.
"""
class Meta:
permissions = (
("announce", "May use @wall to make announcements"),
("boot", "May use @boot to kick players"),
("builder", "Can build and modify objects"),
("chown_all", "Can @chown anything to anyone."),
("free_money", "Has infinite money"),
("long_fingers", "May get/look/examine etc. from a distance"),
("steal", "May give negative money"),
("set_hide", "May set themself invisible"),
("tel_anywhere", "May @teleport anywhere"),
("tel_anyone", "May @teleport anything"),
("see_session_data", "May see detailed player session data"),
("process_control", "May shutdown/restart/reload the game"),
("manage_players", "Can change passwords, siteban, etc."),
)

View file

@ -2,39 +2,39 @@ from django.db import models
import ansi
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)
"""
A generic help entry.
"""
topicname = models.CharField(max_length=255)
entrytext = models.TextField(blank=True, null=True)
staff_only = models.BooleanField(default=0)
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
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

View file

@ -2,43 +2,43 @@ from django.db import models
from django.contrib.auth.models import User
class NewsTopic(models.Model):
"""
Represents a news topic.
"""
name = models.CharField(max_length=75, unique=True)
description = models.TextField(blank=True)
icon = models.ImageField(upload_to='newstopic_icons', default='newstopic_icons/default.png', blank=True, help_text="Image for the news topic.")
"""
Represents a news topic.
"""
name = models.CharField(max_length=75, unique=True)
description = models.TextField(blank=True)
icon = models.ImageField(upload_to='newstopic_icons', default='newstopic_icons/default.png', blank=True, help_text="Image for the news topic.")
def __str__(self):
try:
return self.name
except:
return "Invalid"
def __str__(self):
try:
return self.name
except:
return "Invalid"
class Meta:
ordering = ['name']
class Meta:
ordering = ['name']
class Admin:
list_display = ('name', 'icon')
class Admin:
list_display = ('name', 'icon')
class NewsEntry(models.Model):
"""
An individual news entry.
"""
author = models.ForeignKey(User, related_name='author')
title = models.CharField(max_length=255)
body = models.TextField()
topic = models.ForeignKey(NewsTopic, related_name='newstopic')
date_posted = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.title
"""
An individual news entry.
"""
author = models.ForeignKey(User, related_name='author')
title = models.CharField(max_length=255)
body = models.TextField()
topic = models.ForeignKey(NewsTopic, related_name='newstopic')
date_posted = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.title
class Meta:
ordering = ('-date_posted',)
verbose_name_plural = "News entries"
class Meta:
ordering = ('-date_posted',)
verbose_name_plural = "News entries"
class Admin:
list_display = ('title', 'author', 'topic', 'date_posted')
list_filter = ('topic',)
search_fields = ['title']
class Admin:
list_display = ('title', 'author', 'topic', 'date_posted')
list_filter = ('topic',)
search_fields = ['title']

View file

@ -1,8 +1,8 @@
from django.conf.urls.defaults import *
urlpatterns = patterns('apps.news.views',
(r'^show/(?P<entry_id>\d+)/$', 'show_news'),
(r'^archive/$', 'news_archive'),
(r'^search/$', 'search_form'),
(r'^search/results/$', 'search_results'),
(r'^show/(?P<entry_id>\d+)/$', 'show_news'),
(r'^archive/$', 'news_archive'),
(r'^search/$', 'search_form'),
(r'^search/results/$', 'search_results'),
)

View file

@ -2,8 +2,8 @@
This is a very simple news application, with most of the expected features
like:
* News categories/topics
* Searchable archives
* News categories/topics
* Searchable archives
"""
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
@ -18,109 +18,109 @@ from apps.news.models import NewsTopic, NewsEntry
# The sidebar text to be included as a variable on each page. There's got to
# be a better, cleaner way to include this on every page.
sidebar = """
<p class='doNotDisplay doNotPrint'>This page&rsquo;s menu:</p>
<ul id='side-bar'>
<li><a href='/news/archive'>News Archive</a></li>
<li><a href='/news/search'>Search News</a></li>
</ul>
<p class='doNotDisplay doNotPrint'>This page&rsquo;s menu:</p>
<ul id='side-bar'>
<li><a href='/news/archive'>News Archive</a></li>
<li><a href='/news/search'>Search News</a></li>
</ul>
"""
class SearchForm(forms.Form):
"""
Class to represent a news search form under Django's newforms. This is used
to validate the input on the search_form view, as well as the search_results
view when we're picking the query out of GET. This makes searching safe
via the search form or by directly inputing values via GET key pairs.
"""
search_terms = forms.CharField(max_length=100, min_length=3, required=True)
"""
Class to represent a news search form under Django's newforms. This is used
to validate the input on the search_form view, as well as the search_results
view when we're picking the query out of GET. This makes searching safe
via the search form or by directly inputing values via GET key pairs.
"""
search_terms = forms.CharField(max_length=100, min_length=3, required=True)
def show_news(request, entry_id):
"""
Show an individual news entry. Display some basic information along with
the title and content.
"""
news_entry = get_object_or_404(NewsEntry, id=entry_id)
"""
Show an individual news entry. Display some basic information along with
the title and content.
"""
news_entry = get_object_or_404(NewsEntry, id=entry_id)
pagevars = {
"page_title": "News Entry",
"news_entry": news_entry,
"sidebar": sidebar
}
pagevars = {
"page_title": "News Entry",
"news_entry": news_entry,
"sidebar": sidebar
}
context_instance = RequestContext(request)
return render_to_response('news/show_entry.html', pagevars, context_instance)
context_instance = RequestContext(request)
return render_to_response('news/show_entry.html', pagevars, context_instance)
def news_archive(request):
"""
Shows an archive of news entries.
"""
Shows an archive of news entries.
TODO: Expand this a bit to allow filtering by month/year.
"""
news_entries = NewsEntry.objects.all().order_by('-date_posted')
# TODO: Move this to either settings.py or the SQL configuration.
entries_per_page = 15
TODO: Expand this a bit to allow filtering by month/year.
"""
news_entries = NewsEntry.objects.all().order_by('-date_posted')
# TODO: Move this to either settings.py or the SQL configuration.
entries_per_page = 15
pagevars = {
"page_title": "News Archive",
"browse_url": "/news/archive",
"sidebar": sidebar
}
return gv_list_detail.object_list(request, news_entries, template_name='news/archive.html', extra_context=pagevars, paginate_by=entries_per_page)
pagevars = {
"page_title": "News Archive",
"browse_url": "/news/archive",
"sidebar": sidebar
}
return gv_list_detail.object_list(request, news_entries, template_name='news/archive.html', extra_context=pagevars, paginate_by=entries_per_page)
def search_form(request):
"""
Render the news search form. Don't handle much validation at all. If the
user enters a search term that meets the minimum, send them on their way
to the results page.
"""
if request.method == 'GET':
# A GET request was sent to the search page, load the value and
# validate it.
search_form = SearchForm(request.GET)
if search_form.is_valid():
# If the input is good, send them to the results page with the
# query attached in GET variables.
return HttpResponseRedirect('/news/search/results/?search_terms='+ search_form.cleaned_data['search_terms'])
else:
# Brand new search, nothing has been sent just yet.
search_form = SearchForm()
"""
Render the news search form. Don't handle much validation at all. If the
user enters a search term that meets the minimum, send them on their way
to the results page.
"""
if request.method == 'GET':
# A GET request was sent to the search page, load the value and
# validate it.
search_form = SearchForm(request.GET)
if search_form.is_valid():
# If the input is good, send them to the results page with the
# query attached in GET variables.
return HttpResponseRedirect('/news/search/results/?search_terms='+ search_form.cleaned_data['search_terms'])
else:
# Brand new search, nothing has been sent just yet.
search_form = SearchForm()
pagevars = {
"page_title": "Search News",
"search_form": search_form,
"debug": debug,
"sidebar": sidebar
}
pagevars = {
"page_title": "Search News",
"search_form": search_form,
"debug": debug,
"sidebar": sidebar
}
context_instance = RequestContext(request)
return render_to_response('news/search_form.html', pagevars, context_instance)
context_instance = RequestContext(request)
return render_to_response('news/search_form.html', pagevars, context_instance)
def search_results(request):
"""
Shows an archive of news entries. Use the generic news browsing template.
"""
# TODO: Move this to either settings.py or the SQL configuration.
entries_per_page = 15
"""
Shows an archive of news entries. Use the generic news browsing template.
"""
# TODO: Move this to either settings.py or the SQL configuration.
entries_per_page = 15
# Load the form values from GET to validate against.
search_form = SearchForm(request.GET)
# You have to call is_valid() or cleaned_data won't be populated.
valid_search = search_form.is_valid()
# This is the safe data that we can pass to queries without huge worry of
# badStuff(tm).
cleaned_get = search_form.cleaned_data
# Load the form values from GET to validate against.
search_form = SearchForm(request.GET)
# You have to call is_valid() or cleaned_data won't be populated.
valid_search = search_form.is_valid()
# This is the safe data that we can pass to queries without huge worry of
# badStuff(tm).
cleaned_get = search_form.cleaned_data
# Perform searches that match the title and contents.
# TODO: Allow the user to specify what to match against and in what
# topics/categories.
news_entries = NewsEntry.objects.filter(Q(title__contains=cleaned_get['search_terms']) | Q(body__contains=cleaned_get['search_terms']))
# Perform searches that match the title and contents.
# TODO: Allow the user to specify what to match against and in what
# topics/categories.
news_entries = NewsEntry.objects.filter(Q(title__contains=cleaned_get['search_terms']) | Q(body__contains=cleaned_get['search_terms']))
pagevars = {
"page_title": "Search Results",
"searchtext": cleaned_get['search_terms'],
"browse_url": "/news/search/results",
"sidebar": sidebar
}
return gv_list_detail.object_list(request, news_entries, template_name='news/archive.html', extra_context=pagevars, paginate_by=entries_per_page)
pagevars = {
"page_title": "Search Results",
"searchtext": cleaned_get['search_terms'],
"browse_url": "/news/search/results",
"sidebar": sidebar
}
return gv_list_detail.object_list(request, news_entries, template_name='news/archive.html', extra_context=pagevars, paginate_by=entries_per_page)

View file

@ -1,5 +1,5 @@
from django.conf.urls.defaults import *
urlpatterns = patterns('apps.website.views',
(r'^$', 'page_index'),
(r'^$', 'page_index'),
)

View file

@ -11,47 +11,47 @@ the other applications.
"""
def page_index(request):
"""
Main root page.
"""
# Some misc. configurable stuff.
# TODO: Move this to either SQL or settings.py based configuration.
fpage_player_limit = 4
fpage_news_entries = 2
# A QuerySet of recent news entries.
news_entries = NewsEntry.objects.all().order_by('-date_posted')[:fpage_news_entries]
# Dictionary containing database statistics.
objstats = functions_db.object_totals()
# A QuerySet of the most recently connected players.
recent_players = functions_db.get_recently_connected_players()[:fpage_player_limit]
pagevars = {
"page_title": "Front Page",
"news_entries": news_entries,
"players_connected_recent": recent_players,
"num_players_connected": functions_db.get_connected_players().count(),
"num_players_registered": functions_db.num_total_players(),
"num_players_connected_recent": functions_db.get_recently_connected_players().count(),
"num_players_registered_recent": functions_db.get_recently_created_players().count(),
"num_players": objstats["players"],
"num_rooms": objstats["rooms"],
"num_things": objstats["things"],
"num_exits": objstats["exits"],
}
"""
Main root page.
"""
# Some misc. configurable stuff.
# TODO: Move this to either SQL or settings.py based configuration.
fpage_player_limit = 4
fpage_news_entries = 2
# A QuerySet of recent news entries.
news_entries = NewsEntry.objects.all().order_by('-date_posted')[:fpage_news_entries]
# Dictionary containing database statistics.
objstats = functions_db.object_totals()
# A QuerySet of the most recently connected players.
recent_players = functions_db.get_recently_connected_players()[:fpage_player_limit]
pagevars = {
"page_title": "Front Page",
"news_entries": news_entries,
"players_connected_recent": recent_players,
"num_players_connected": functions_db.get_connected_players().count(),
"num_players_registered": functions_db.num_total_players(),
"num_players_connected_recent": functions_db.get_recently_connected_players().count(),
"num_players_registered_recent": functions_db.get_recently_created_players().count(),
"num_players": objstats["players"],
"num_rooms": objstats["rooms"],
"num_things": objstats["things"],
"num_exits": objstats["exits"],
}
context_instance = RequestContext(request)
return render_to_response('index.html', pagevars, context_instance)
context_instance = RequestContext(request)
return render_to_response('index.html', pagevars, context_instance)
def to_be_implemented(request):
"""
A notice letting the user know that this particular feature hasn't been
implemented yet.
"""
"""
A notice letting the user know that this particular feature hasn't been
implemented yet.
"""
pagevars = {
"page_title": "To Be Implemented...",
}
pagevars = {
"page_title": "To Be Implemented...",
}
context_instance = RequestContext(request)
return render_to_response('tbi.html', pagevars, context_instance)
context_instance = RequestContext(request)
return render_to_response('tbi.html', pagevars, context_instance)

View file

@ -2,10 +2,10 @@ from django.conf import settings
import gameconf
def general_context(request):
"""
Returns common Evennia-related context stuff.
"""
return {
'game_name': gameconf.get_configvalue('site_name'),
'media_url': settings.MEDIA_URL,
}
"""
Returns common Evennia-related context stuff.
"""
return {
'game_name': gameconf.get_configvalue('site_name'),
'media_url': settings.MEDIA_URL,
}