Exemple #1
0
def create(show_record: ShowRecord,
           current_user: str = Depends(get_current_user)):
    """
    create a show record
    """

    try:
        show = Show()
        show.artist = show_record.artist
        show.venue = show_record.venue
        show.city = show_record.city
        show.date = show_record.date
        show.festival = show_record.festival
        show.creator_id = current_user.id

        db.add(show)
        db.commit()
    except sqlalchemy.exc.IntegrityError:
        return {
            "code": "error",
            "message": "User already exists with that username or email"
        }
    except Exception as e:
        print(e)

    return {"code": "SUCCESS"}