示例#1
0
文件: views.py 项目: Alapan/pollApp
def get_publishedPolls
    
    '''Retrieve list of published polls'''
    poll_list = []
    published_polls = get_value('published_polls')

    if not published_polls:
        set_value('published_polls',[])

    # p is a poll key
    for p in published_polls:

        poll_list = get_value(p)
        polls.append(poll_list)
示例#2
0
文件: views.py 项目: Alapan/pollApp
def publish_poll(key):

    '''Add poll with published=True to list of published polls'''    
    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)
示例#3
0
文件: views.py 项目: Alapan/pollApp
def unpublish_poll(key):

    '''Remove poll with published=False from list of published polls'''
    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
文件: views.py 项目: Alapan/pollApp
def cast_vote(question_key, choice):

    '''Sets vote of selected choice of question to 1'''
    poll = get_value(question_key)
    for d in poll['choices']:
        if d['options'] == choice:
            d['votes'] += 1

    set_value(question_key, poll)
    return poll
示例#5
0
文件: views.py 项目: Alapan/pollApp
def get_poll(key):

    '''Retrieve a single poll'''
    poll = get_value(key)
    return poll