]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Add flash messaging. Failures do not work yet.
authorAnt Zucaro <azucaro@gmail.com>
Wed, 18 Jun 2014 01:30:37 +0000 (21:30 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Wed, 18 Jun 2014 01:30:37 +0000 (21:30 -0400)
xonstat/templates/merge.mako
xonstat/views/admin.py

index 9704f212e68ca9df6aa0307e995e302cecfb37d4..d1fc10f4cc976b3527c00d4170a17ef6e7ab0174 100644 (file)
@@ -9,6 +9,26 @@ ${nav.nav('players')}
 
 <h2>Merge two players below.</h2>
 
+% if len(request.session.peek_flash("failure")) > 0:
+<div class="row">
+  <div class="span6">
+    <div class="alert alert-error">
+      <button type="button" class="close" data-dismiss="alert">&times;</button>
+      ${request.session.pop_flash("failure")[0]}
+    </div>
+  </div>
+</div>
+% endif
+
+% if len(request.session.peek_flash("success")) > 0:
+<div class="row">
+  <div class="alert alert-success">
+    <button type="button" class="close" data-dismiss="alert">&times;</button>
+    ${request.session.pop_flash("success")[0]}
+  </div>
+</div>
+% endif
+
 <div class="row">
   <div class="span6">
     <form style="margin-top:20px;" class="form-horizontal">
index 520f779c03e47d53b960e9eae2b1fd4ce63351b5..8d5c20c885cf66a08c922a1406f279ffc5f732fc 100644 (file)
@@ -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 {}