def post(self): user = users.get_current_user() if not user: self.redirect('/') else: 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: board_id, link, errors = utils.validate_input(board_id, link) if errors: self.render('public.html', id=board_id, link=link, errors=errors, actions=constants.ACTIONS, signout=constants.SIGNOUT) else: feed_url = utils.create_feed( user,board_id, title,link, description, actions, public_board=True, get_all=False, token=None ) self.render('congrats.html',feed_url=feed_url,signout=constants.SIGNOUT) else: # They didn't mark any of the checkboxes self.render('public.html',check_error=True,actions=constants.ACTIONS,signout=constants.SIGNOUT)
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)