Skip to content

Commit

Permalink
added members only access. added members can post updates
Browse files Browse the repository at this point in the history
  • Loading branch information
progrium committed Mar 27, 2010
1 parent 3928910 commit 4926154
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app.yaml
Expand Up @@ -13,4 +13,5 @@ handlers:
- url: /static
static_dir: static
- url: .*
script: main.py
script: main.py
login: required
13 changes: 12 additions & 1 deletion main.py
@@ -1,4 +1,5 @@
from google.appengine.ext import webapp, db
from google.appengine.api import urlfetch, memcache, users
from google.appengine.ext.webapp import util, template

class Update(db.Model):
Expand All @@ -10,8 +11,18 @@ class Update(db.Model):

class MainHandler(webapp.RequestHandler):
def get(self):
your_name = "Jeff"
user = users.get_current_user()
if user:
logout_url = users.create_logout_url('/')
else:
login_url = users.create_login_url('/')
updates = Update.all().order('-created')
self.response.out.write(template.render('templates/main.html', locals()))

def post(self):
update = Update(body=self.request.get('body'))
update.put()
self.redirect('/')


def main():
Expand Down
9 changes: 8 additions & 1 deletion templates/main.html
@@ -1,6 +1,13 @@
{% extends 'base.html' %}
{% block content %}

Hello world, {{your_name}}!
<form method="post">
<textarea name="body"></textarea><br />
<input type="submit" value="Update" />
</form>

{% for update in updates %}
<p>{{update.body}} | {{update.created|timesince}} ago | {{update.user.nickname}}</p>
{% endfor %}

{% endblock %}

0 comments on commit 4926154

Please sign in to comment.