def create_answer(request_data): user_id = request_data['userId'] question_id = request_data['questionId'] answer_string = request_data['answerString'] question_object = question_get_handler.get_question_by_id(question_id) try: answer_object = Answer.objects.create(user_id=user_id, answer_string=answer_string, question=question_object) return answer_object except: raise InternalServerError()
def create_answer(request_data, username): # user_id = request_data['userId'] # import pdb; pdb.set_trace() question_id = request_data['questionId'] answer_string = request_data['answerString'] question_object = question_get_handler.get_question_by_id(question_id) print question_object try: answer_object = Answer.objects.create(user_id=username, answer_string=answer_string, question=question_object) return answer_object except: raise InternalServerError()
def create_upvote(request_data): user_id = request_data['userId'] answer_id = request_data['answerId'] answer_object = answer_get_handler.get_answer_by_id(answer_id) try: upvote_object, is_created = Upvote.objects.get_or_create( user_id=user_id, answer=answer_object) return upvote_object except Exception as e: print e raise InternalServerError()
def create_upvote(request_data): auth_token = request.cookies.get('auth_key') is_valid, user_object = user_service.validate_and_get_user(auth_token) username = user_object['username'] answer_id = request_data['answerId'] answer_object = answer_get_handler.get_answer_by_id(answer_id) try: upvote_object, is_created = Upvote.objects.get_or_create(user_id=username, answer=answer_object) return upvote_object except Exception as e: print e raise InternalServerError()