Wire up a simple forbidden response for merges.
authorAnt Zucaro <azucaro@gmail.com>
Tue, 10 Jun 2014 00:57:36 +0000 (20:57 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Tue, 10 Jun 2014 00:57:36 +0000 (20:57 -0400)
xonstat/__init__.py
xonstat/templates/forbidden.mako [new file with mode: 0644]
xonstat/templates/merge.mako [new file with mode: 0644]
xonstat/views/__init__.py
xonstat/views/admin.py [new file with mode: 0644]

index 37c661e..ef16ec9 100644 (file)
@@ -160,4 +160,10 @@ def main(global_config, **settings):
     config.add_route("search_json", "search.json")
     config.add_view(search_json, route_name="search_json", renderer="jsonp")
 
     config.add_route("search_json", "search.json")
     config.add_view(search_json, route_name="search_json", renderer="jsonp")
 
+    # ADMIN ROUTES
+    config.add_forbidden_view(forbidden, renderer="forbidden.mako")
+
+    config.add_route("merge",      "/merge")
+    config.add_view(route_name="merge", renderer="merge.mako", permission="admin")
+
     return config.make_wsgi_app()
     return config.make_wsgi_app()
diff --git a/xonstat/templates/forbidden.mako b/xonstat/templates/forbidden.mako
new file mode 100644 (file)
index 0000000..42054ae
--- /dev/null
@@ -0,0 +1,11 @@
+<%inherit file="base.mako"/>
+<%namespace name="nav" file="nav.mako" />
+
+<%block name="navigation">
+${nav.nav('players')}
+</%block>
+
+<h1>403 Forbidden</h1>
+
+<h2>Sorry dudebro!</h2>
+<p>Access to this area is restricted. You should probably get back to the game. It's cooler anyway!</p>
diff --git a/xonstat/templates/merge.mako b/xonstat/templates/merge.mako
new file mode 100644 (file)
index 0000000..da82beb
--- /dev/null
@@ -0,0 +1,11 @@
+<%inherit file="base.mako"/>
+<%namespace name="nav" file="nav.mako" />
+
+<%block name="navigation">
+${nav.nav('players')}
+</%block>
+
+<h1>Player Merge</h1>
+
+<h2>Merge two players below. The destination player_id is on the right.</h2>
+<p>(the destination player_id is the one that lives on after the merge)</p>
index 4e65f2c..a084bcc 100644 (file)
@@ -28,3 +28,5 @@ from xonstat.views.exceptions   import notfound
 
 from xonstat.views.main   import main_index, top_players_by_time, top_servers_by_players
 from xonstat.views.main   import top_servers_by_players, top_maps_by_times_played
 
 from xonstat.views.main   import main_index, top_players_by_time, top_servers_by_players
 from xonstat.views.main   import top_servers_by_players, top_maps_by_times_played
+
+from xonstat.views.admin   import forbidden
diff --git a/xonstat/views/admin.py b/xonstat/views/admin.py
new file mode 100644 (file)
index 0000000..f46aca2
--- /dev/null
@@ -0,0 +1,8 @@
+from pyramid.response import Response
+from pyramid.httpexceptions import HTTPForbidden
+
+def forbidden(request):
+    '''A simple forbidden view. Does nothing more than set the status and then
+    gets the heck out of dodge. The forbidden.mako template does the work.'''
+    request.response.status = 403
+    return {}