def poll(poll_id): poll = Poll.get_poll_by_id(poll_id) if not poll: return abort(404) choices = Choice.get_choices_for_poll(poll) return views.view_poll(poll, choices)
def choice_create(poll_id): poll = Poll.get_poll_by_id(poll_id) if not poll: return abort(404) choice = PollServices.create_new_choice_for_poll_from_post_data( poll, request.form) return redirect(url_for('poll', poll_id=poll.id))
def poll(poll_id): poll = Poll.get_poll_by_id(poll_id) if not poll: return abort(404) choices = Choice.get_choices_for_poll(poll) #csrf_token = generate_csrf() return views.view_poll(poll, choices, csrf_token=None)
def test_get_poll_by_id(self, app): with app.app_context(): now = datetime.now() p = Poll(id=None, name="Nom", date=now) p.save() new_poll = Poll.get_poll_by_id(1) assert new_poll.id == 1 assert new_poll.name == "Nom" assert new_poll.date == str(now)
def poll_vote(poll_id): poll = Poll.get_poll_by_id(poll_id) if not poll: return abort(404) choice_id = request.form['choice_id'] choice = Choice.get_by_id_for_poll(poll, choice_id) if not choice: return abort(404) choice.cast_vote() return redirect(url_for('poll', poll_id=poll.id))