From: Ant Zucaro Date: Wed, 18 Jun 2014 01:30:37 +0000 (-0400) Subject: Add flash messaging. Failures do not work yet. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=18b96e6f5fef6f7dabb531e799c67cc173f834be;p=xonotic%2Fxonstat.git Add flash messaging. Failures do not work yet. --- diff --git a/xonstat/templates/merge.mako b/xonstat/templates/merge.mako index 9704f21..d1fc10f 100644 --- a/xonstat/templates/merge.mako +++ b/xonstat/templates/merge.mako @@ -9,6 +9,26 @@ ${nav.nav('players')}

Merge two players below.

+% if len(request.session.peek_flash("failure")) > 0: +
+
+
+ + ${request.session.pop_flash("failure")[0]} +
+
+
+% endif + +% if len(request.session.peek_flash("success")) > 0: +
+
+ + ${request.session.pop_flash("success")[0]} +
+
+% endif +
diff --git a/xonstat/views/admin.py b/xonstat/views/admin.py index 520f779..8d5c20c 100644 --- a/xonstat/views/admin.py +++ b/xonstat/views/admin.py @@ -41,8 +41,6 @@ def merge(request): if request.params.has_key("csrf_token"): # check the token to prevent request forgery st = request.session.get_csrf_token() - log.debug("Session token is %s" % st) - log.debug("Request token is %s" % request.params.get('csrf_token')) check_csrf_token(request) if request.params.has_key("w_pid") and request.params.has_key("l_pid"): @@ -56,7 +54,15 @@ def merge(request): s.commit() + request.session.flash( + "Successfully merged player %s into %s!" % (l_pid, w_pid), + "success") + except: s.rollback() + request.session.flash( + "Could not merge player %s into %s." % (l_pid, w_pid), + "failure") + return {}