Exemplo n.º 1
0
 def set_no_help(self, actor, question_id, answer_id):
   question = Question.get_by_id(int(question_id))
   answer = Answer.get_by_id(parent = question.key, id = int(answer_id))
   relation = AccountQuestionRelationService().get_relationship(actor.key, question.key)
   if not answer.key in relation.no_help_answers:
     relation.no_help_answers.append(answer.key)
   
   relation.put()
Exemplo n.º 2
0
  def remove_answer_from_question(self, question_id, answer_id):
    question = Question.get_by_id(int(question_id))
    if not question:
      return
      
    answer = Answer.get_by_id(int(answer_id), parent = question.key)
    if not answer:
      return

    answer.key.delete()
    self.update_answer_num(question.key)
    return question
Exemplo n.º 3
0
 def voteup_answer(self, actor, question_id, answer_id):
   question = Question.get_by_id(int(question_id))
   answer = Answer.get_by_id(parent = question.key, id = int(answer_id))
   relation = AccountQuestionRelationService().get_relationship(actor.key, question.key)
   if answer.key in relation.up_voted_answers:
     relation.up_voted_answers = [ a for a in relation.up_voted_answers if a != answer.key ]
     answer.up_voted_users = [ u for u in answer.up_voted_users if u != actor.key ]
   else:
     relation.up_voted_answers.append(answer.key)
     answer.up_voted_users.append(actor.key)
     
   relation.down_voted_answers = [ a for a in relation.down_voted_answers if a != answer.key ]
   answer.down_voted_users = [ u for u in answer.down_voted_users if u != actor.key ]
   answer.put()
   relation.put()
Exemplo n.º 4
0
  def update_answer(self, question_id, answer_id, source):
    current_question = Question.get_by_id(int(question_id))
    if not current_question:
      return
      
    answer = Answer.get_by_id(int(answer_id), parent = current_question.key)
    #TODO: raise 404 error.
    if not answer:
      return
    
    #TODO: filter desc content using hlper method.
    content = source.replace("\n", "<br />")
    
    answer.content = content
    answer.source = source

    answer.put()
Exemplo n.º 5
0
 def cancel_no_help(self, actor, question_id, answer_id):
   question = Question.get_by_id(int(question_id))
   answer = Answer.get_by_id(parent = question.key, id = int(answer_id))
   relation = AccountQuestionRelationService().get_relationship(actor.key, question.key)
   relation.no_help_answers = [ a for a in relation.no_help_answers if a != answer.key ]
   relation.put()