Esempio n. 1
0
 def post(self):
     user = users.get_current_user()
     if not user:
         self.redirect('/')
     current_user = User.query().filter(User.email == user.email()).get()
     if not current_user:
         new_user_entry = User(
             name=self.request.get("name"),
             username=self.request.get("username"),
             email=user.email(),
         )
         new_user_entry.put()
         current_user = new_user_entry
     else:
         new_post = Post(author=current_user.key,
                         content=self.request.get("user_post"))
         new_post.put()
     time.sleep(.2)
     self.redirect('/welcome')
Esempio n. 2
0
 def post(self):
     user = users.get_current_user()
     if user is None:
         self.redirect('/')
         return  # lol idk if this is ok?? it works I guess
     current_user = User.query().filter(User.email == user.email()).get()
     if not current_user:
         # upon new user form submission, create new user and store in datastore
         new_user_entry = User(
             name=self.request.get("name"),
             username=self.request.get("username"),
             email=user.email(),
         )
         new_user_entry.put()
         current_user = new_user_entry
     else:
         # if not a new user, existing user submitted a post from feed
         new_post = Post(author=current_user.key,
                         content=self.request.get("user_post"))
         new_post.put()
     time.sleep(.2)
     self.redirect('/forum')