def post(self): args = auth_parser.parse_args() user = authentication_header_parser(args['Authorization']) if user: return {'Authorized': None}, http.client.OK return '', http.client.UNAUTHORIZED
def get(self): args = auth_parser.parse_args() user = authentication_header_parser(args['Authorization']) artist = ArtistModel.query.filter_by(user_id=user['id']).first() if not artist: return '', http.client.NOT_FOUND return artist
def get(self): args = auth_parser.parse_args() user_data = authentication_header_parser(args['Authorization']) user = UserModel.query.filter_by(id=user_data['id']).first() if not user: return '', http.client.NOT_FOUND return user
def delete(self): args = delete_parser.parse_args() user = authentication_header_parser(args['Authorization']) artist = ArtistModel.query.filter_by(user_id=user['id']).first() if artist: if not is_password_valid(artist.user, args['password']): return '', http.client.BAD_REQUEST db.session.delete(artist) db.session.commit() return '', http.client.NO_CONTENT
def delete(self): args = delete_parser.parse_args() user_data = authentication_header_parser(args['Authorization']) user = UserModel.query.filter_by(id=user_data['id']).first() if user: if not is_password_valid(user, args['password']): return '', http.client.BAD_REQUEST db.session.delete(user) db.session.commit() return '', http.client.NO_CONTENT
def patch(self): args = artist_parser.parse_args() user = authentication_header_parser(args['Authorization']) artist = ArtistModel.query.filter_by(user_id=user['id']).first() if not artist: return '', http.client.NOT_FOUND for key, val in args.items(): if hasattr(artist, key): setattr(artist, key, val) db.session.commit() result = api_namespace.marshal(artist, artist_model) return result, http.client.OK
def post(self): args = artist_parser.parse_args() user = authentication_header_parser(args['Authorization']) new_artist = ArtistModel( name=args['name'], location=args['location'], bio=args['bio'], website=args['website'], user_id=user['id'] ) db.session.add(new_artist) db.session.commit() result = api_namespace.marshal(new_artist, artist_model) return result, http.client.CREATED