Skip to content

Commit

Permalink
Allow users to answer questions
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristian Vargas committed Mar 17, 2016
1 parent 7c0f207 commit 3f22694
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions qa/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down

0 comments on commit 3f22694

Please sign in to comment.