コード例 #1
0
ファイル: admin.py プロジェクト: mnceleiro/GAE-Blog
 def post(self):
     self.name = self.request.get('name')
     self.author = str(users.get_current_user())
     
     if (users.is_current_user_admin()):
         post = Post(name = self.name, description = self.request.get('description').encode('utf-8'), author = self.author)
         post.put()
         return self.redirect('/?msg=El post se ha realizado correctamente')
     else:
         return self.redirect('/?msg=No puede escribir posts porque no es administrador del sitio web.')
コード例 #2
0
def create_post(urlsafe_chatroom_id, user_email, content):
    chatroom = get_chatroom(urlsafe_chatroom_id)
    if chatroom.status != 'active':
        raise ValueError(
            "Posts cannot be published while chatroom is suspended.")
    post = Post(chatroom_key=chatroom.key,
                user_email=user_email,
                content=content)
    post.put()

    return post
コード例 #3
0
 def post(self):
     subject = self.request.get('subject')
     content = self.request.get('content')
     # let's check we have a subject and a content
     if subject and content:
         post = Post(subject=subject,
                     content=content,
                     user=User.by_id(self.uid()))
         # post creation
         post.put()
         self.redirect('/')
     # if something is wrong let's show the error
     else:
         error = 'Sorry, we need both, title and content.'
         self.render_new_post(subject, content, error)
コード例 #4
0
ファイル: main.py プロジェクト: manelromero/blog
 def post(self):
     subject = self.request.get('subject')
     content = self.request.get('content')
     # let's check we have a subject and a content
     if subject and content:
         post = Post(
             subject=subject,
             content=content,
             user=User.by_id(self.uid())
             )
         # post creation
         post.put()
         self.redirect('/')
     # if something is wrong let's show the error
     else:
         error = 'Sorry, we need both, title and content.'
         self.render_new_post(subject, content, error)