def poll_options(poll_id): poll = repository.get_poll_by_id(poll_id) return render_template('poll.html', poll=_poll_viewmodel(poll))
def edit_poll(poll_id): poll = repository.get_poll_by_id(poll_id) return render_template('edit-poll.html', poll=_poll_viewmodel(poll))
def get_two_random_and_different_options(poll_id): poll = repository.get_poll_by_id(poll_id) return random.sample(poll.options, 2)
def compute_vote(poll_id, winner_name, loser_name): poll = repository.get_poll_by_id(poll_id) poll.vote(poll.get_option_by_name(winner_name), poll.get_option_by_name(loser_name)) repository.insert_poll(poll)
def add_option_to_poll(poll_id, option): poll = repository.get_poll_by_id(poll_id) poll.add_option(option) repository.insert_poll(poll)