versions/v2/review.py
def create_review(current_user, businessId):
    """Create Review given a business ID
    Takes current user ID and business ID then attachs it to response data
    """
    data = request.get_json()
    _reviewer = User.query.get(current_user)
    _business = Business.query.get(businessId)

    if not _business:
        return jsonify({'warning': 'Business Not Found'}), 404

    # create new review instances
    new_review = Review(
        title=data['title'],
        desc=data['desc'],
        business=_business,
        reviewer=_reviewer
    )

    # Commit changes to db
    new_review.save()

    # Send response if business was saved
    if new_review.id:
        # create a notification if review is created
        if current_user != _business.owner.id:
            new_notification = Notification(
                recipient=_business.owner,
                actor=_reviewer.username,
                business_id=businessId,
                review_id=new_review.id
            )
            new_notification.save()

        return jsonify({
            'success': 'successfully created review',
            'review': {
                'id': new_review.id,
                'title': new_review.title,
                'reviewer': new_review.reviewer.username,
                'desc': new_review.desc
            }
        }), 201

    return jsonify({'warning': 'Could not create new reviews'}), 401
Create Review given a business ID
    Takes current user ID and business ID then attachs it to response data
    
Create Review given a business ID
Takes current user ID and business ID then attachs it to response data
Create Review given a business ID Takes current user ID and business ID then attachs it to response data
def create_review(current_user, businessId):
    data = request.get_json()
    _reviewer = User.query.get(current_user)
    _business = Business.query.get(businessId)
    if not _business:
        return jsonify({'warning': 'Business Not Found'}), 404
    new_review = Review(
        title=data['title'],
        desc=data['desc'],
        business=_business,
        reviewer=_reviewer
    )
    new_review.save()
    if new_review.id:
        if current_user != _business.owner.id:
            new_notification = Notification(
                recipient=_business.owner,
                actor=_reviewer.username,
                business_id=businessId,
                review_id=new_review.id
            )
            new_notification.save()
        return jsonify({
            'success': 'successfully created review',
            'review': {
                'id': new_review.id,
                'title': new_review.title,
                'reviewer': new_review.reviewer.username,
                'desc': new_review.desc
            }
        }), 201
    return jsonify({'warning': 'Could not create new reviews'}), 401
def create_review ( current_user , businessId ) : data = request . get_json ( ) _reviewer = User . query . get ( current_user ) _business = Business . query . get ( businessId ) if not _business : return jsonify ( { 'warning' : 'Business Not Found' } ) , 404 new_review = Review ( title = data [ 'title' ] , desc = data [ 'desc' ] , business = _business , reviewer = _reviewer ) new_review . save ( ) if new_review . id : if current_user != _business . owner . id : new_notification = Notification ( recipient = _business . owner , actor = _reviewer . username , business_id = businessId , review_id = new_review . id ) new_notification . save ( ) return jsonify ( { 'success' : 'successfully created review' , 'review' : { 'id' : new_review . id , 'title' : new_review . title , 'reviewer' : new_review . reviewer . username , 'desc' : new_review . desc } } ) , 201 return jsonify ( { 'warning' : 'Could not create new reviews' } ) , 401
Create Review given a business ID
Takes current user ID and business ID then attachs it to response data
Create Review given a business ID Takes current user ID and business ID then attachs it to response data
"""Create Review given a business ID
    Takes current user ID and business ID then attachs it to response data
    """ # create new review instances # Commit changes to db # Send response if business was saved # create a notification if review is created
current_user
businessId