コード例 #1
0
ファイル: main.py プロジェクト: naiyt/trellorss-gae
    def post(self):
        """
        Handles adding tokens and creating private boards.
        TODO: Refactor this into a couple of handlers, and include the public board handling as well
        to make the code more succinct and extensible. This method is too long and unwieldy.

        """

        token = self.request.get('token')
        user = users.get_current_user()
        if not user:
            self.redirect('/')
        user_obj = utils.get_user(user)
        if token: # Adding a token for a user
            if utils.verify_token(token):
                user_obj.auth_token = token
                user_obj.put()
                self.redirect('/privatefeeds')
            else:
                args = constants.TOKEN_ARGS
                auth_url = "https://trello.com/1/authorize?%s" % urlencode(args)
                self.render('private.html',
                    actions=constants.ACTIONS,
                    incorrect_token=True,
                    auth_url=auth_url,
                    signout=constants.SIGNOUT)
        else: # Adding a board for a user
            board_id = self.request.get('board')
            title = self.request.get('title')
            link = self.request.get('link')
            description = self.request.get('description')
            actions = [x for x in constants.ACTIONS if self.request.get(x)]

            if actions:
                get_all = False
                if board_id == 'all':
                    get_all = True
                    board_id = None
                feed_url = utils.create_feed(
                    user,board_id,
                    title,link,
                    description,actions,
                    public_board=False,
                    get_all=get_all,
                    token=user_obj.auth_token)
                self.render('congrats.html',feed_url=feed_url,signout=constants.SIGNOUT)
            else: # They missed some required info
                user_boards = utils.find_boards(user_obj)
                self.render('private.html',
                    actions=constants.ACTIONS,
                    check_error=True,
                    user_boards=user_boards,
                    link=link,
                    description=description,
                    title=title,
                    signout=constants.SIGNOUT)
コード例 #2
0
ファイル: main.py プロジェクト: naiyt/trellorss-gae
 def get(self):
     user = users.get_current_user()
     if user:
         user_obj = utils.get_user(user)
         if(utils.verify_token(user_obj.auth_token)):
             self.redirect('/')
         else:
             args = constants.TOKEN_ARGS
             auth_url = "https://trello.com/1/authorize?%s" % urlencode(args)
             self.render('reauth.html',auth_url=auth_url,signout=constants.SIGNOUT)
     else:
         self.redirect('/')
コード例 #3
0
ファイル: main.py プロジェクト: naiyt/trellorss-gae
 def get(self):
     user = users.get_current_user()
     if user:
         user_obj = utils.get_user(user)
         feeds = utils.get_feeds(user_obj.feeds)
         if user_obj.auth_token: # User has an auth token
             if(utils.verify_token(user_obj.auth_token)): # User's auth token is valid
                 self.render('profile.html', signout=constants.SIGNOUT,feeds=feeds)
             else: # User's auth token is out of date
                 self.redirect('/reauth')
         else: # User has no auth token
             self.render('profile.html', signout=constants.SIGNOUT,feeds=feeds)
     else:
         login_url = users.create_login_url(self.request.uri)
         self.render('index.html', login=login_url)
コード例 #4
0
ファイル: main.py プロジェクト: naiyt/trellorss-gae
 def post(self):
     token = self.request.get('token')
     user = users.get_current_user()
     if not user:
         self.redirect('/')
     user_obj = utils.get_user(user)
     if token:
         if(utils.verify_token(token)):
             user_obj.auth_token = token
             user_obj.put()
             self.redirect('/')
         else:
             args = constants.TOKEN_ARGS
             auth_url = "https://trello.com/1/authorize?%s" % urlencode(args)
             self.render('reauth.html',incorrect_token=True,auth_url=auth_url,signout=constants.SIGNOUT)
     else:
         self.redirect('/')