Exemple #1
0
    def post(self):
        user = users.get_current_user()
        if not user:
            # Send the user to the login page
            self.redirect(users.create_login_url(self.request.uri))
            return

        assert user
        newKey = None
        if (self.request.get(Constants.ACTION_WORDS_PARAM) and
            self.request.get(Constants.REDIRECT_LINK_PARAM)):
            if self.request.get(Constants.ACTION_ID_PARAM):
                newAction = ndb.Key('Action', int(self.request.get(Constants.ACTION_ID_PARAM)),
                                    parent=getAccountKey(user.user_id())).get()
            else:
                newAction = Action(parent=getAccountKey(user.user_id()))
                newAction.user_id = user.user_id()

            newAction.redirect_link = self.request.get(Constants.REDIRECT_LINK_PARAM)
            newAction.actionwords = UserInput(
                self.request.get(Constants.ACTION_WORDS_PARAM)).getAllActionWords()
            newKey = newAction.put()
            if self.request.get(Constants.AJAX_REQUEST_PARAM):
                return ajaxSuccess(self)

            return self.redirect(listPagePath(Constants.NEW_KEY_PARAM, str(newKey.id())))
        if self.request.get(Constants.AJAX_REQUEST_PARAM):
            return ajaxFailure(self)
        template_values = { 'user_nickname': user.nickname(),
                            'Constants': Constants.instance(),
                            'actionwords_input': self.request.get(Constants.ACTION_WORDS_PARAM),
                            'redirect_link_input': self.request.get(Constants.REDIRECT_LINK_PARAM)}

        template = JINJA_ENVIRONMENT.get_template('add.html')
        self.response.write(template.render(template_values))
Exemple #2
0
    def get(self):
        user = users.get_current_user()
        if not user:
            # Send the user to the login page
            self.redirect(users.create_login_url(self.request.uri))
            return

        assert user
        match = self.request.get(Constants.MATCH_PARAM, '')
        highlightKey = self.request.get(Constants.NEW_KEY_PARAM, '0')
        matchingUserActions = fetchMatchingActions(match, user)
        template_values = { 'user_nickname': user.nickname(),
                            'matching_actions': matchingUserActions,
                            'user_id': user.user_id(),
                            'match': match,
                            'Constants': Constants.instance(),
                            'highlight_key': int(highlightKey)}

        template = JINJA_ENVIRONMENT.get_template('list.html')
        self.response.write(template.render(template_values))