Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Change the index page to work for non logged in users

  • Loading branch information...
commit c10faa72002a6169b05f78c3b25f830bced21686 1 parent 2b443bb
@karenc authored
Showing with 9 additions and 4 deletions.
  1. +6 −3 src/controller.py
  2. +3 −1 src/templates/index.html
View
9 src/controller.py
@@ -3,6 +3,7 @@
import re
from google.appengine.ext import webapp
+from google.appengine.api import users
from Hunt import Hunt, Clue, Team
import utils
@@ -42,15 +43,17 @@ def parse_json_objs(objs, fields):
class Index(webapp.RequestHandler):
- @utils.logged_in
def get(self):
- hunts = list(Hunt.all().filter('owner =', self.user))
+ user = users.get_current_user()
+ hunts = []
+ if user:
+ hunts = list(Hunt.all().filter('owner =', user))
self.response.out.write(utils.render('templates/index.html', {'hunts': hunts}))
class CreateHunt(webapp.RequestHandler):
@utils.logged_in
- def post(self):
+ def get(self):
hunt_name = self.request.get('hunt-name')
hunt = Hunt.all().filter('name =', hunt_name).filter('owner =', self.user).get()
if not hunt:
View
4 src/templates/index.html
@@ -9,12 +9,13 @@
<div id="content">
<div>
<h2>Create a new Hunt:</h2>
- <form action="create-hunt" method="post">
+ <form action="create-hunt">
<label for="hunt-name">Hunt Name:</label>
<input type="text" name="hunt-name" id="hunt-name" />
<input type="submit" value="Create" />
</form>
</div>
+ {% if hunts %}
<div>
<h2>Your Hunts:</h2>
<table class="with-color">
@@ -38,6 +39,7 @@
{% endfor %}
</table>
</div>
+ {% endif %}
</div>
</body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.