From: Ant Zucaro Date: Tue, 10 Jun 2014 00:57:36 +0000 (-0400) Subject: Wire up a simple forbidden response for merges. X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonstat.git;a=commitdiff_plain;h=8cba4091ba2c9d89d16083f1ff2360500cff5ac5;ds=sidebyside Wire up a simple forbidden response for merges. --- diff --git a/xonstat/__init__.py b/xonstat/__init__.py index 37c661e..ef16ec9 100644 --- a/xonstat/__init__.py +++ b/xonstat/__init__.py @@ -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") + # 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() diff --git a/xonstat/templates/forbidden.mako b/xonstat/templates/forbidden.mako new file mode 100644 index 0000000..42054ae --- /dev/null +++ b/xonstat/templates/forbidden.mako @@ -0,0 +1,11 @@ +<%inherit file="base.mako"/> +<%namespace name="nav" file="nav.mako" /> + +<%block name="navigation"> +${nav.nav('players')} + + +

403 Forbidden

+ +

Sorry dudebro!

+

Access to this area is restricted. You should probably get back to the game. It's cooler anyway!

diff --git a/xonstat/templates/merge.mako b/xonstat/templates/merge.mako new file mode 100644 index 0000000..da82beb --- /dev/null +++ b/xonstat/templates/merge.mako @@ -0,0 +1,11 @@ +<%inherit file="base.mako"/> +<%namespace name="nav" file="nav.mako" /> + +<%block name="navigation"> +${nav.nav('players')} + + +

Player Merge

+ +

Merge two players below. The destination player_id is on the right.

+

(the destination player_id is the one that lives on after the merge)

diff --git a/xonstat/views/__init__.py b/xonstat/views/__init__.py index 4e65f2c..a084bcc 100644 --- a/xonstat/views/__init__.py +++ b/xonstat/views/__init__.py @@ -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.admin import forbidden diff --git a/xonstat/views/admin.py b/xonstat/views/admin.py new file mode 100644 index 0000000..f46aca2 --- /dev/null +++ b/xonstat/views/admin.py @@ -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 {}