예제 #1
0
파일: views.py 프로젝트: kyroskoh/Lab
def get_polls():
    poll_list = []
    published_polls = get_value('published_polls')
    if not published_polls:
        set_value('published_polls', [])
    for p in published_polls:
        poll = get_value(p)
        poll_list.append(poll)
    return poll_list
예제 #2
0
def get_polls():
    poll_list = []
    published_polls = get_value('published_polls')
    if not published_polls:
        set_value('published_polls',[])
    for p in published_polls:
        poll = get_value(p)
        poll_list.append(poll)
    return poll_list
예제 #3
0
def unpublish_polls(key):
    published_polls = get_value('published_polls')   
    if not published_polls:               
        set_value('published_polls',[])  
    if key in published_polls:
        published_polls.remove(key)
        set_value('published_polls',published_polls)
예제 #4
0
def publish_poll(key):
    published_polls = get_value('published_polls')
    if not published_polls:               
        set_value('published_polls',[])   
    if key not in published_polls:
        published_polls.append(key)
        set_value('published_polls',published_polls)
예제 #5
0
def cast_vote(poll_key,choice):
    poll = get_value(poll_key)
    for c in poll['choices']:
        if c['id'] == int(choice):
            c['value'] += 1
    set_value(poll_key,poll)
    return poll
예제 #6
0
파일: views.py 프로젝트: kyroskoh/Lab
def unpublish_polls(key):
    published_polls = get_value('published_polls')
    if not published_polls:
        set_value('published_polls', [])
    if key in published_polls:
        published_polls.remove(key)
        set_value('published_polls', published_polls)
예제 #7
0
파일: views.py 프로젝트: kyroskoh/Lab
def publish_poll(key):
    published_polls = get_value('published_polls')
    if not published_polls:
        set_value('published_polls', [])
    if key not in published_polls:
        published_polls.append(key)
        set_value('published_polls', published_polls)
예제 #8
0
파일: views.py 프로젝트: kyroskoh/Lab
def cast_vote(poll_key, choice):
    poll = get_value(poll_key)
    for c in poll['choices']:
        if c['id'] == int(choice):
            c['value'] += 1
    set_value(poll_key, poll)
    return poll
예제 #9
0
파일: app.py 프로젝트: Alapan/pollApp
    def edit(self, key, **kwargs):

        method = cherrypy.request.method.upper()
        poll = FALSE
        obj = Poll()
        data = {
            'title': 'Edit your poll',
            'url': get_links()
        }
        if method == 'POST':
            obj.edit_poll(**kwargs)
            data['poll'] = poll
            data['success'] = True

        else:

            data['poll'] = get_value(key)

        temp = env.get_template('edit_poll.html')
        return temp.render(data)
예제 #10
0
def get_poll(key):
    poll = get_value(key)
    return poll
예제 #11
0
파일: views.py 프로젝트: kyroskoh/Lab
def get_poll(key):
    poll = get_value(key)
    return poll