API: user - minor refactor
This commit is contained in:
		@@ -152,19 +152,7 @@ def get_user_status(user_id):
 | 
			
		||||
    user = User.query.filter_by(id=user_id).first()
 | 
			
		||||
    response_object = {
 | 
			
		||||
        'status': 'success',
 | 
			
		||||
        'data': {
 | 
			
		||||
            'id': user.id,
 | 
			
		||||
            'username': user.username,
 | 
			
		||||
            'email': user.email,
 | 
			
		||||
            'created_at': user.created_at,
 | 
			
		||||
            'admin': user.admin,
 | 
			
		||||
            'first_name': user.first_name,
 | 
			
		||||
            'last_name': user.last_name,
 | 
			
		||||
            'bio': user.bio,
 | 
			
		||||
            'location': user.location,
 | 
			
		||||
            'birth_date': user.birth_date,
 | 
			
		||||
            'picture': True if user.picture else False,
 | 
			
		||||
        }
 | 
			
		||||
        'data': user.serialize()
 | 
			
		||||
    }
 | 
			
		||||
    return jsonify(response_object), 200
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -76,3 +76,18 @@ class User(db.Model):
 | 
			
		||||
            return 'Signature expired. Please log in again.'
 | 
			
		||||
        except jwt.InvalidTokenError:
 | 
			
		||||
            return 'Invalid token. Please log in again.'
 | 
			
		||||
 | 
			
		||||
    def serialize(self):
 | 
			
		||||
        return {
 | 
			
		||||
            'id': self.id,
 | 
			
		||||
            'username': self.username,
 | 
			
		||||
            'email': self.email,
 | 
			
		||||
            'created_at': self.created_at,
 | 
			
		||||
            'admin': self.admin,
 | 
			
		||||
            'first_name': self.first_name,
 | 
			
		||||
            'last_name': self.last_name,
 | 
			
		||||
            'bio': self.bio,
 | 
			
		||||
            'location': self.location,
 | 
			
		||||
            'birth_date': self.birth_date,
 | 
			
		||||
            'picture': self.picture is not None
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user