Example #1
0
 def post(self):
     title = cgi.escape(self.request.get('title'))
     content = cgi.escape(self.request.get('content'))
     
     userID = users.get_current_user().user_id()
     
     note = Note(parent = ndb.Key('note',userID), title=title, content=content)
     note.put()
     
     self.redirect("/my-dashboard")
Example #2
0
  def get(self):
    template_values = {}
    
    current_user = users.get_current_user()
    if current_user == None:					# returns to homepage if no user logged in
      template_values['loginURL'] = users.create_login_url(dest_url='my-dashboard')
      template = jinja_environment.get_template('home.html')
      self.response.out.write(template.render(template_values))
    else:
      name = users.get_current_user()
      logout = users.create_logout_url('/')
      userID = users.get_current_user().user_id()

      notes = Note.query(ancestor=ndb.Key('note', userID)).fetch()
      images = Image.query(ancestor=ndb.Key('image', userID)).fetch()
      
      # allURLs = []
      # for image in images:
      #     url = get_serving_url(image.blobKey, size=None, crop=False, secure_url=None)
      #     allURLs.append(url)
            
      template_values = {
       'notes': notes,
       'name' : name, 
       'current_user': current_user,
       'logout' : logout,
       'images' : images
      }
      
      template = jinja_environment.get_template('my-dashboard.html')
      self.response.out.write(template.render(template_values))