Skip to content

Commit

Permalink
Change the index page to work for non logged in users
Browse files Browse the repository at this point in the history
  • Loading branch information
karenc committed Aug 9, 2011
1 parent 2b443bb commit c10faa7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion src/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ <h1>Welcome to SMS Hunt!</h1>
<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">
Expand All @@ -38,6 +39,7 @@ <h2>Your Hunts:</h2>
{% endfor %}
</table>
</div>
{% endif %}
</div>
</body>
</html>

0 comments on commit c10faa7

Please sign in to comment.