示例#1
0
def poll_options(poll_id):
    poll = repository.get_poll_by_id(poll_id)
    return render_template('poll.html', poll=_poll_viewmodel(poll))
示例#2
0
def edit_poll(poll_id):
    poll = repository.get_poll_by_id(poll_id)
    return render_template('edit-poll.html', poll=_poll_viewmodel(poll))
示例#3
0
def get_two_random_and_different_options(poll_id):
    poll = repository.get_poll_by_id(poll_id)
    return random.sample(poll.options, 2)
示例#4
0
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)
示例#5
0
def add_option_to_poll(poll_id, option):
    poll = repository.get_poll_by_id(poll_id)
    poll.add_option(option)
    repository.insert_poll(poll)