From 3f22694bae607b0f0e3aff7e381176688a220ba2 Mon Sep 17 00:00:00 2001 From: Cristian Vargas Date: Thu, 17 Mar 2016 17:43:23 -0500 Subject: [PATCH] Allow users to answer questions --- qa/views.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/qa/views.py b/qa/views.py index 6665434..dd0f6df 100644 --- a/qa/views.py +++ b/qa/views.py @@ -235,20 +235,20 @@ def add_answer(request): question = Question.objects.get(pk=question_id) user_ob = get_user_model().objects.get(id=user_id) - user = UserQAProfile.objects.get(user=user_ob) + user = user_ob.userqaprofile user.points += 5 user.save() if answer_text.strip() == '': return render(request, 'qa/answer.html', {'question': question, 'message': 'Empty'}) - a = Answer() + answer = Answer() pub_date = datetime.datetime.now() - a.answer_text = answer_text - a.question = question - a.user_data = user - a.pub_date = pub_date - a.save() + answer.answer_text = answer_text + answer.question = question + answer.user = user_ob + answer.pub_date = pub_date + answer.save() answer_list = question.answer_set.order_by('-votes')