Ejemplo n.º 1
0
    def put(self, user_id):
        user = UserModel.find_user_by_id(user_id)

        if user is None:
            return {
                'message': 'the user you are trying to edit doesn\'t exist'
            }

        firstname = self.get_value('firstname')
        lastname = self.get_value('lastname')
        avatar = self.get_value('avatar')

        if firstname:
            user.firstname = firstname
        if lastname:
            user.lastname = lastname
        if avatar:
            user.avatar = avatar

        user.save_to_db()
        return user.to_json()
Ejemplo n.º 2
0
    def get(self, user_id):
        user = UserModel.find_user_by_id(user_id)

        if user:
            return user.to_json(), 200
        return {'message': 'user not found'}, 404