Skip to content

Commit

Permalink
chore(polls): remove unneeded debug log statements
Browse files Browse the repository at this point in the history
  • Loading branch information
theo-o committed Oct 13, 2019
1 parent 74fe734 commit 1a89144
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions intranet/apps/polls/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,15 @@ def poll_vote_view(request, poll_id):
entries = request.POST
for name in entries:
if name.startswith("question-"):
logger.debug(name)

question_num = name.split("question-", 2)[1]
logger.debug(question_num)
try:
question_obj = questions.get(num=question_num)
except Question.DoesNotExist:
messages.error(request, "Invalid question passes with num {}".format(question_num))
continue
logger.debug(question_obj)

choice_num = entries[name]
logger.debug(choice_num)

if question_obj.is_choice():
choices = question_obj.choice_set.all()
Expand All @@ -129,13 +125,11 @@ def poll_vote_view(request, poll_id):
messages.error(request, "Invalid answer choice with num {}".format(choice_num))
continue
else:
logger.debug(choice_obj)
Answer.objects.filter(user=user, question=question_obj).delete()
Answer.objects.create(user=user, question=question_obj, choice=choice_obj)
messages.success(request, "Voted for {} on {}".format(choice_obj, question_obj))
elif question_obj.is_many_choice():
total_choices = request.POST.getlist(name)
logger.debug("total choices: %s", total_choices)
if len(total_choices) == 1 and total_choices[0] == "CLEAR":
Answer.objects.filter(user=user, question=question_obj).delete()
Answer.objects.create(user=user, question=question_obj, clear_vote=True)
Expand All @@ -144,7 +138,6 @@ def poll_vote_view(request, poll_id):
messages.error(request, "Cannot select other options with Clear Vote.")
else:
current_choices = Answer.objects.filter(user=user, question=question_obj)
logger.debug("current choices: %s", current_choices)
current_choices_nums = [c.choice.num if c.choice else None for c in current_choices]
# delete entries that weren't checked but in db
for c in current_choices_nums:
Expand Down Expand Up @@ -200,8 +193,6 @@ def poll_vote_view(request, poll_id):
}
questions.append(question)

logger.debug(questions)

can_vote = poll.can_vote(user)
context = {"poll": poll, "can_vote": can_vote, "user": user, "questions": questions, "question_types": Question.get_question_types()}
return render(request, "polls/vote.html", context)
Expand Down

0 comments on commit 1a89144

Please sign in to comment.