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
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
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)
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)
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
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)
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)
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
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)
def get_poll(key): poll = get_value(key) return poll