versions/v2/business.py
def create_business(current_user):
    """Creates a business
    Takes current_user ID and update data
    test if actually saved
    """
    data = request.get_json()

    # Check if there is an existing business with same name
    if existing_module('business', data['name']):
        return jsonify({
            'warning': 'Business name {} already taken'.format(data['name'])
        }), 409

    business_owner = get_in_module('user', current_user)

    # create new business instances
    new_business = Business(
        name=data['name'],
        logo=data['logo'],
        location=data['location'],
        category=data['category'],
        bio=data['bio'],
        owner=business_owner
    )

    # Commit changes to db
    new_business.save()

    # Send response if business was saved
    if new_business.id:
        return jsonify({
            'success': 'successfully created business',
            'business': {
                'id': new_business.id,
                'name': new_business.name,
                'location': new_business.location,
                'category': new_business.category,
                'bio': new_business.bio,
                'owner': new_business.owner.username
            }
        }), 201

    return jsonify({'warning': 'Could not create new business'}), 401
Creates a business
    Takes current_user ID and update data
    test if actually saved
    
Creates a business
Takes current_user ID and update data
test if actually saved
Creates a business Takes current_user ID and update data test if actually saved
def create_business(current_user):
    data = request.get_json()
    if existing_module('business', data['name']):
        return jsonify({
            'warning': 'Business name {} already taken'.format(data['name'])
        }), 409
    business_owner = get_in_module('user', current_user)
    new_business = Business(
        name=data['name'],
        logo=data['logo'],
        location=data['location'],
        category=data['category'],
        bio=data['bio'],
        owner=business_owner
    )
    new_business.save()
    if new_business.id:
        return jsonify({
            'success': 'successfully created business',
            'business': {
                'id': new_business.id,
                'name': new_business.name,
                'location': new_business.location,
                'category': new_business.category,
                'bio': new_business.bio,
                'owner': new_business.owner.username
            }
        }), 201
    return jsonify({'warning': 'Could not create new business'}), 401
def create_business ( current_user ) : data = request . get_json ( ) if existing_module ( 'business' , data [ 'name' ] ) : return jsonify ( { 'warning' : 'Business name {} already taken' . format ( data [ 'name' ] ) } ) , 409 business_owner = get_in_module ( 'user' , current_user ) new_business = Business ( name = data [ 'name' ] , logo = data [ 'logo' ] , location = data [ 'location' ] , category = data [ 'category' ] , bio = data [ 'bio' ] , owner = business_owner ) new_business . save ( ) if new_business . id : return jsonify ( { 'success' : 'successfully created business' , 'business' : { 'id' : new_business . id , 'name' : new_business . name , 'location' : new_business . location , 'category' : new_business . category , 'bio' : new_business . bio , 'owner' : new_business . owner . username } } ) , 201 return jsonify ( { 'warning' : 'Could not create new business' } ) , 401
Creates a business
Takes current_user ID and update data
test if actually saved
Creates a business Takes current_user ID and update data test if actually saved
"""Creates a business
    Takes current_user ID and update data
    test if actually saved
    """ # Check if there is an existing business with same name # create new business instances # Commit changes to db # Send response if business was saved
current_user