Add basic views for player and game info, plus the supporting templates.
authorAnt Zucaro <azucaro@gmail.com>
Thu, 5 May 2011 10:34:22 +0000 (06:34 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Thu, 5 May 2011 10:34:22 +0000 (06:34 -0400)
development.ini
xonstat/__init__.py
xonstat/templates/base.mako [new file with mode: 0644]
xonstat/templates/game_info.mako [new file with mode: 0644]
xonstat/templates/player_info.mako [new file with mode: 0644]
xonstat/views.py

index a9ab682..1fa50f9 100644 (file)
@@ -13,6 +13,7 @@ session.lock_dir = %(here)s/data/sessions/lock
 session.key = xonstat
 session.secret = 433fa4b080c2147c79c0ed1cb54e3ce81371fb34
 jinja2.directories = xonstat:templates
+mako.directories = xonstat:templates
 
 [pipeline:main]
 pipeline =
index 3cf3f3e..93e27da 100644 (file)
@@ -21,8 +21,16 @@ def main(global_config, **settings):
 
     config.add_static_view('static', 'xonstat:static')
 
+    # routes
     config.add_route(name="main_index", pattern="/", view=main_index, 
             renderer='index.jinja2') 
+
+    config.add_route(name="player_info", pattern="/player/{id}", view=player_info, 
+            renderer='player_info.mako') 
+
+    config.add_route(name="game_info", pattern="/game/{id}", view=game_info, 
+            renderer='game_info.mako') 
+
     config.add_route(name="stats_submit", pattern="stats/submit", 
             view=stats_submit, renderer='index.jinja2') 
 
diff --git a/xonstat/templates/base.mako b/xonstat/templates/base.mako
new file mode 100644 (file)
index 0000000..59ba3f7
--- /dev/null
@@ -0,0 +1,18 @@
+<html>
+   <head>
+      <title><%block name="title">XonStat - The Xonotic Statistics Database</%block></title>
+         <%block name="css"/>
+         <%block name="js"/>
+   </head>
+   <body>
+      <div id="header">
+         <%block name="header"/>
+         </div>
+
+         ${self.body()}
+
+         <div id="footer">
+         <%block name="footer"/>
+         </div>
+   </body>
+</html>
diff --git a/xonstat/templates/game_info.mako b/xonstat/templates/game_info.mako
new file mode 100644 (file)
index 0000000..8f9f4c6
--- /dev/null
@@ -0,0 +1,22 @@
+<%inherit file="base.mako"/>
+
+<%block name="title">
+Game Information - ${parent.title()}
+</%block>
+
+
+% if game is None:
+<h2>Sorry, that game wasn't found!</h2>
+
+% else:
+<h2>Game Detail</h2>
+<ul>
+   <li>ID: ${game.game_id}</li>
+   <li>Time: ${game.start_dt}</li>
+   <li>Game Type: ${game.game_type_cd}</li>
+   <li>Server: ${game.server_id}</li>
+   <li>Map: ${game.map_id}</li>
+   <li>Duration: ${game.duration}</li>
+   <li>Winner: ${game.duration}</li>
+</ul>
+% endif
diff --git a/xonstat/templates/player_info.mako b/xonstat/templates/player_info.mako
new file mode 100644 (file)
index 0000000..e177e42
--- /dev/null
@@ -0,0 +1,23 @@
+<%inherit file="base.mako"/>
+
+<%block name="title">
+% if player:
+Player Information for ${player.nick} - 
+% endif
+
+${parent.title()}
+</%block>
+
+
+% if player is None:
+<h2>Sorry, that player wasn't found!</h2>
+
+% else:
+<h2>Player Detail</h2>
+<ul>
+   <li>Nickname: ${player.nick}</li>
+   <li>ID: ${player.player_id}</li>
+   <li>Location: ${player.location}</li>
+   <li>Joined: ${player.create_dt}</li>
+</ul>
+% endif
index fd0ce6f..db331c3 100755 (executable)
@@ -30,10 +30,29 @@ def player_index(request):
 
 @view_config(renderer='player_info.mako')
 def player_info(request):
-    player = DBSession.query(Player).filter_by(player_id=p_player_id)
-    log.debug("testing logging; entered PlayerHandler.info()")
+    player_id = request.matchdict['id']
+    try:
+        player = DBSession.query(Player).filter_by(player_id=player_id).one()
+    except:
+        player = None
+    log.debug("entered player_info")
     return {'player':player}
 
+
+##########################################################################
+# This is the game views area - only views pertaining to Xonotic
+# games and their related information goes here
+##########################################################################
+def game_info(request):
+    game_id = request.matchdict['id']
+    try:
+        game = DBSession.query(Game).filter_by(game_id=game_id).one()
+    except:
+        game = None
+    log.debug("entered game_info")
+    return {'game':game}
+
+
 ##########################################################################
 # This is the stats views area - only views pertaining to Xonotic
 # statistics and its related information goes here