31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
|
from django.contrib import messages
|
||
|
from django.core.urlresolvers import reverse
|
||
|
from django.http import HttpResponseRedirect
|
||
|
from django.shortcuts import render_to_response, get_object_or_404
|
||
|
from django.template import RequestContext
|
||
|
|
||
|
from storycraft.models import StorycraftGame, StorycraftLine, StorycraftPlayer
|
||
|
|
||
|
def index(request):
|
||
|
"""Display a short list of each game (and its summary) in the system.
|
||
|
|
||
|
TODO: add paginator.
|
||
|
"""
|
||
|
|
||
|
games = StorycraftGame.objects.all()
|
||
|
return render_to_response('storycraft/index.html', {'games': games}, context_instance=RequestContext(request))
|
||
|
|
||
|
def game_index(request, game_id):
|
||
|
"""Display one individual game's details, including the story, if it's done."""
|
||
|
|
||
|
game = get_object_or_404(StorycraftGame, pk=game_id)
|
||
|
players = StorycraftPlayer.objects.filter(game=game.id)
|
||
|
lines = []
|
||
|
|
||
|
if game.is_completed():
|
||
|
lines = StorycraftLine.objects.filter(game=game.id)
|
||
|
|
||
|
return render_to_response('storycraft/game_index.html', {'game': game, 'players': players, 'lines': lines}, context_instance=RequestContext(request))
|
||
|
|
||
|
# vi:tabstop=4:expandtab:autoindent
|