Run Migrations! Added a is_connected field to Players to be able to more conveniently access online status from out-of-process (resolves issue 251). Also cleaned up and added features to the default website.

This commit is contained in:
Griatch 2012-09-17 19:19:20 +02:00
parent c53a9b5770
commit 21137cc830
10 changed files with 189 additions and 75 deletions

View file

@ -1,5 +1,5 @@
/***************************************
* TITLE: Prosimii Screen Stylesheet *
* TITLE: Prosimii Screen Stylesheet *
* URI : prosimii/prosimii-screen.css *
* MODIF: 2004-Apr-28 21:43 +0800 *
***************************************/
@ -312,7 +312,7 @@ dd {
.filler { /* use with an empty <p> element to add padding to the end of a text box */
border: 1px solid white;
}
.noBorderOnLeft {
border-left: none;
}
@ -356,4 +356,4 @@ dd {
#footer a:hover {
text-decoration: none;
}
}

View file

@ -8,28 +8,30 @@
{% block content %}
<div class="rowOfBoxes">
<div class="twoThirds noBorderOnLeft">
<!--div class="twoThirds noBorderOnLeft"-->
<div class="noBorderOnLeft">
<h1>Welcome!</h1>
<p>Welcome to your new installation of <a href="http://evennia.com">Evennia</a>, your friendly
neighborhood next-generation MUD server. You are looking at Evennia's web
neighborhood next-generation MUD development system and server. You are looking at Evennia's web
presence, which can be expanded to a full-fledged site as
needed. Through the <a href="/admin">admin interface</a> you can view and edit the
database without logging into the game.
{% if webclient_enabled %}
database without logging into the game.
{% if webclient_enabled %}
You can also connect to the game directly from your browser using our
<a href='/webclient'>online client</a>!<br></br>
<a href='/webclient'>online client</a>!<br></br>
{% endif %}
For more info, take your time to
peruse our extensive online <a href="http://code.google.com/p/evennia/wiki/Index">documentation</a>.
<p>
Should you have any questions, concerns, bug reports, or
if you want to help out, don't hesitate to come join the
<a href="http://evennia.com/discussions">Evennia community</a> and get
your voice heard!
if you want to help out, don't hesitate to join the Evennia community to make your voice heard! Drop a mail to the
<a href="http://evennia.com/discussions">mailing list</a> or to come say hi in the <a href="http://webchat.freenode.net/?channels=evennia">developer chatroom</a>. If you find bugs, please report them to our <a href="http://code.google.com/p/evennia/issues/list">Issue tracker</a>.
</p>
</div>
<div class="oneThird">
<!-- news app commented out since there are no news in the database originally -->
<!--div class="oneThird">
<h1>Latest News</h1>
{% for entry in news_entries %}
<a href="/news/show/{{entry.id}}" class="newsHeading">{{entry.topic.name}}: {{entry.title}}</a>
@ -39,8 +41,8 @@
<div class="more"><a href="/news/archive">More News &raquo;</a></div>
<p class="filler"><!-- Filler para to extend left vertical line --></p>
</div>
<p class="filler"><!-- Filler para to extend left vertical line--></p>
</div-->
</div>
<div class="rowOfBoxes dividingBorderAbove">
@ -48,8 +50,7 @@
<div class="quarter noBorderOnLeft">
<h1>Players</h1>
<p>
There are currently <strong>{{num_players_connected}}</strong> connected,
and a total of <strong>{{num_players_registered}}</strong> registered. Of these, <strong>{{num_players_registered_recent}}</strong> were created this week, and <strong>{{num_players_connected_recent}}</strong> have connected within the last seven days.
There's currently <strong>{{num_players_connected}}</strong> connected out of a total of <strong>{{num_players_registered}}</strong> players registered. Of these, <strong>{{num_players_registered_recent}}</strong> were created this week, and <strong>{{num_players_connected_recent}}</strong> have connected within the last seven days.
</p>
</div>
@ -66,15 +67,16 @@
<div class="quarter">
<h1>Database Stats</h1>
<ul>
<li>{{num_players_registered}} players</li>
<li>{{num_rooms}} rooms ({{num_exits}} exits) </li>
<li>{{num_objects}} objects total</li>
<li>{{num_players_registered}} players (+ {{num_characters}} characters)</li>
<li>{{num_rooms}} rooms (+ {{num_exits}} exits)</li>
<li>{{num_others}} other objects</li>
</ul>
</div>
<div class="quarter">
<h1>Evennia</h1>
<p><a href="http://evennia.com">Evennia</a> is MUD server built in
<p><a href="http://evennia.com">Evennia</a> is an open-source MUD server built in
<a href="http://python.org">Python</a>, on top of the
<a href="http://twistedmatrix.com">Twisted</a> and
<a href="http://djangoproject.com">Django</a> frameworks. This

View file

@ -1,50 +1,59 @@
"""
This file contains the generic, assorted views that don't fall under one of
the other applications. Views are django's way of processing e.g. html
the other applications. Views are django's way of processing e.g. html
templates on the fly.
"""
from django.shortcuts import render_to_response, get_object_or_404
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib.auth.models import User
#from django.contrib.auth.models import User
from django.conf import settings
from src.server.models import ServerConfig
from src.objects.models import ObjectDB
from src.typeclasses.models import TypedObject
#from src.typeclasses.models import TypedObject
from src.players.models import PlayerDB
from src.web.news.models import NewsEntry
_BASE_CHAR_TYPECLASS = settings.BASE_CHARACTER_TYPECLASS
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_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]
# A QuerySet of the most recently connected players.
recent_users = PlayerDB.objects.get_recently_connected_players()[:fpage_player_limit]
nplyrs_conn_recent = len(recent_users) or "none"
nplyrs = PlayerDB.objects.num_total_players() or "none"
nplyrs_reg_recent = len(PlayerDB.objects.get_recently_created_players()) or "none"
nsess = len(PlayerDB.objects.get_connected_players()) or "noone"
exits = ObjectDB.objects.filter(db_destination__isnull=False)
rooms = [room for room in ObjectDB.objects.filter(db_home__isnull=True) if room not in exits]
nobjs = ObjectDB.objects.all().count()
nrooms = ObjectDB.objects.filter(db_location__isnull=True).exclude(db_typeclass_path=_BASE_CHAR_TYPECLASS).count()
nexits = ObjectDB.objects.filter(db_location__isnull=False, db_destination__isnull=False).count()
nchars = ObjectDB.objects.filter(db_typeclass_path=_BASE_CHAR_TYPECLASS).count()
nothers = nobjs - nrooms - nchars - nexits
pagevars = {
"page_title": "Front Page",
"news_entries": news_entries,
"players_connected_recent": recent_users,
"num_players_connected": ServerConfig.objects.conf('nr_sessions'),#len(PlayerDB.objects.get_connected_players()),
"num_players_registered": PlayerDB.objects.num_total_players(),
"num_players_connected_recent": len(PlayerDB.objects.get_recently_connected_players()),
"num_players_registered_recent": len(PlayerDB.objects.get_recently_created_players()),
"num_rooms": len(rooms),
"num_exits": len(exits),
"num_objects" : ObjectDB.objects.all().count()
"num_players_connected": nsess or "noone",
"num_players_registered": nplyrs or "no",
"num_players_connected_recent": nplyrs_conn_recent or "no",
"num_players_registered_recent": nplyrs_reg_recent or "noone",
"num_rooms": nrooms or "none",
"num_exits": nexits or "no",
"num_objects" : nobjs or "none",
"num_characters": nchars or "no",
"num_others": nothers or "no"
}
context_instance = RequestContext(request)