Ejemplo n.º 1
0
 def create(cls, question_id, user_email, comment, **__):
     question = Question.get(question_id, user_email)
     command = DB.comments.insert(
         dict(
             q_id=question_id,
             owner_email=user_email,
             content=comment,
             score=0,
         ))
     DB.ex(command)
     User.get(user_email)  # forces a user check / creation
     question = Question.get(question_id, user_email)
     ## increment comment count
     comments = Comment.get_all_for_question(question, override_auth=True)
     return {
         "question": question,
         "comments": comments,
     }
Ejemplo n.º 2
0
 def get(cls, question_id, comment_id, user_email, **__):
     Question.get(question_id, user_email)  # forces a permission check
     comment_command = DB.comments.select(
         (DB.comments.columns.id == comment_id)
         & (DB.comments.columns.q_id == question_id))
     return r2d(DB.ex(comment_command).fetchone())