Esempio n. 1
0
def post_to_notes(req):
  user = users.get_current_user()
  if not user:
      return req.redirect(users.create_login_url(req.uri.application_uri()))
  text = req.get('text')
  note = Note(owner=user.user_id(),text=text)
  note.put()
  return req.redirect(req.uri.server_uri()+'/notes')
Esempio n. 2
0
def get_notes(req):
  user = users.get_current_user()
  if not user:
      return req.redirect(users.create_login_url(req.uri.application_uri()))
  t = Template(req,'notes.html',TEMPLATE_PATH)
  t.assign('title','SimpleRepository: Notes') 
  t.assign('notes',Note.get_list_by_user(user))
  req.res.body = t.fetch() 
Esempio n. 3
0
def delete_note(req):
  user = users.get_current_user()
  if not user:
      return req.redirect(users.create_login_url(req.uri.application_uri()))
  id = int(req.get('id'))
  note = Note.get_by_id(id) 
  note.delete()
  return req.redirect(req.uri.server_uri()+'/notes')