Example #1
0
 def index(self):
     data = {
         'title': 'Poll list',
         'links': get_links()
     }
     temp = env.get_template('polls.html')
     return temp.render(data)
Example #2
0
    def index(self):

        data = {
            'title': 'Welcome to the poll application',
            'links': get_links()            
        }
        temp =env.get_template('index.html')
        return temp.render(data)
Example #3
0
    def add(self, **kwargs):
        method = cherrypy.request.method.upper()
        poll = False
        obj = Poll()
        data = {
            
            'title': 'Add a poll',
            'url': get_links()
        }
        if method == 'POST':
            obj.add_poll(**kwargs)
            data['success'] = True

        temp = env.get_template('add_poll.html')
        return temp.render(data)
Example #4
0
    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)
Example #5
0
    def poll(self, key, choice=None):
        
        method = cherrypy.request.method.upper()
        poll = False
        data = {
            'title': 'Poll',
            'links': get_links()
        }

        if method == 'POST':
            data['poll'] = cast_vote(key, choice)
            data['success'] = True

        #GET request
        else:
            data['poll'] = get_poll(key)
        
        if not data.get('poll'):
            raise cherrypy.HTTPError(404)
        
        temp = env.get_template('polls.html')
        return temp.render(data)