Add a simple form for the versus view.
authorAnt Zucaro <azucaro@gmail.com>
Sat, 12 Mar 2016 14:22:26 +0000 (09:22 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Sat, 12 Mar 2016 14:22:26 +0000 (09:22 -0500)
xonstat/templates/player_versus.mako
xonstat/views/player.py

index 8f81a45..01600a4 100644 (file)
@@ -6,6 +6,7 @@
   ${nav.nav('players')}
 </%block>
 
+% if p1 is not None and p2 is not None:
 <div class="row">
   <div class="small-5 columns text-right">
     <h3>${p1.nick_html_colors()|n}</h3>
   </div>
 </div>
 % endif
+
+% else:
+
+<div class="row">
+  <div class="small-12 large-8 large-offset-2 columns">
+
+    <form class="form-horizontal">
+      <fieldset>
+
+        <div class="row">
+          <div class="small-5 columns">
+            <div class="control-group">
+              <label class="control-label">Player #1</label>
+              <div class="controls">
+                <input id="p1" name="p1" type="text" class="input-xlarge">
+              </div>
+            </div>
+          </div>
+
+          <div class="small-2 columns text-center">
+            <h3>vs</h3>
+          </div>
+
+          <div class="small-5 columns">
+            <div class="control-group">
+              <label class="control-label">Player #2</label>
+              <div class="controls">
+                <input id="p2" name="p2" type="text" class="input-xlarge">
+              </div>
+            </div>
+          </div>
+
+        </div>
+
+        <!-- Button -->
+        <div class="control-group">
+          <label class="control-label"></label>
+          <div class="controls">
+            <button id="submit" name="submit" type="submit" class="btn btn-primary">Compare!</button>
+          </div>
+        </div>
+
+      </fieldset>
+    </form>
+
+  </div>
+</div>
+
+% endif
index 7668774..83238ad 100644 (file)
@@ -1167,9 +1167,18 @@ def player_versus_data(request):
 
     except Exception as e:
         log.debug(e)
-        raise pyramid.httpexceptions.HTTPNotFound
+
+        p1_id = None
+        p2_id = None
+        p1 = None
+        p2 = None
+        p1_wins = None
+        p2_wins = None
+        rgs = None
 
     return {
+            "p1_id" : p1_id,
+            "p2_id" : p2_id,
             "p1" : p1,
             "p2" : p2,
             "p1_wins" : p1_wins,