示例#1
0
    def get(self, user_id):
        """
        @api {GET} /users/id/<String:user_id> Get user by id
        @apiGroup User
        @apiDescription Get user details by id

        @apiSuccessExample {JSON} Success-Response:
            {
                UserModel
            }
        """
        user_model = UserHandler().get(value=user_id)
        if user_model:
            return user_model.jsonify()
        HttpException.throw_404("User with id '{user_id}' not found".format(user_id=user_id))
    def get(self, username):
        """
        @api {GET} /users/name/<String:username> Get user by username
        @apiGroup User
        @apiDescription Get user details by username

        @apiSuccessExample {JSON} Success-Response:
            {
                UserModel
            }
        """
        user_model = UserHandler().get(value=username, by="username")
        if user_model:
            # Intentional bug that returns UserModel without firstname attribute
            user_model = copy.deepcopy(user_model)
            del user_model.firstname
            return user_model.jsonify()
        HttpException.throw_404(
            "User with username '{username}' not found".format(
                username=username))
示例#3
0
 def verify_invitation_exists(self):
     if self.check_invitation_exists():
         return True
     HttpException.throw_404(
         "Invitation with {by} '{value}' not found".format(
             by=self.by, value=self.value))
 def verify_message_exists(self):
     if self.check_message_exists():
         return True
     HttpException.throw_404("Message with {by} '{value}' not found".format(
         by=self.by, value=self.value))