示例#1
0
文件: app.py 项目: Alapan/pollApp
 def index(self):
     data = {
         'title': 'Poll list',
         'links': get_links()
     }
     temp = env.get_template('polls.html')
     return temp.render(data)
示例#2
0
文件: app.py 项目: Alapan/pollApp
    def index(self):

        data = {
            'title': 'Welcome to the poll application',
            'links': get_links()            
        }
        temp =env.get_template('index.html')
        return temp.render(data)
示例#3
0
文件: app.py 项目: Alapan/pollApp
    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)
示例#4
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)
示例#5
0
文件: app.py 项目: Alapan/pollApp
    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)