Ejemplo n.º 1
0
def create_venue_submission():
    genres = request.form.getlist("genres")
    data = request.form.to_dict()
    data["genres"] = genres
    data["seeking_talent"] = (True if data.get("seeking_talent", False) is "y"
                              else False)
    venue = Venue(**data)
    result = venue.save_to_db()
    if result["error"]:
        flash("An error occurred. Venue " + data["name"] +
              " could not be listed.")
        abort(500)
    flash("Venue " + data["name"] + " was successfully listed!")
    return render_template("pages/home.html")
Ejemplo n.º 2
0
 def create_venue(self, *args, **kwargs):
     """Create venue for Organizer"""
     args[0]["organizer_id"] = self.id
     venue = Venue()
     for key, value in args[0].items():
         setattr(venue, key, value)
     try:
         venue.save()
         return venue
     except exc.IntegrityError as e:
         print("venue")
         errorInfo = e.orig.args
         print(errorInfo[0])  # This will give you error code
         print(errorInfo[1])  # This will give you error message
Ejemplo n.º 3
0
def create_venue():
    validate_coordinates(request.json.get('latitude', None), request.json.get('longitude', None))
    venue = Venue(from_dict=request.json)
    venue.departementCode = 'XX'  # avoid triggerring check on this
    siret = request.json.get('siret')
    if not siret:
        venue.generate_validation_token()
    save_venue(venue)

    if not venue.isValidated:
        try:
            send_venue_validation_email(venue, send_raw_email)
        except MailServiceException as e:
            app.logger.error('Mail service failure', e)

    return jsonify(as_dict(venue, includes=VENUE_INCLUDES)), 201
Ejemplo n.º 4
0
def create_venue_submission():
    try:
        venue = Venue()
        fill_venue_data(venue)
        db.session.add(venue)
        db.session.commit()

        flash('Venue ' + request.form['name'] + ' was successfully listed!')
    except:
        print(sys.exc_info())
        db.session.rollback()
        flash('An error occurred. Venue could not be created.')
    finally:
        db.session.close()

    return render_template('pages/home.html')
Ejemplo n.º 5
0
def populate_db():
    if app.config["POPULATE_DB"]:
        for artist in ARTISTS:
            db.session.add(Artist(**artist))

        for show in SHOWS:
            db.session.add(Show(**show))

        for venue in VENUES:
            db.session.add(Venue(**venue))

        try:
            db.session.commit()
        except exc.SQLAlchemyError:
            db.session.rollback()
            print(sys.exc_info())
        finally:
            db.session.close()
Ejemplo n.º 6
0
def create_venue_submission():
    error = False
    venue_name = request.get_json()['name']
    try:
        body = {}
        venue = Venue(name=venue_name)
        city_name = request.get_json()['city']
        state_id = request.get_json()['state']
        genres = request.get_json()['genres']
        city = City.query.filter(City.name == city_name).first()

        if city == None:
            city = City(name=city_name)
            city.state_id = state_id

        venue.city = city
        venue.phone = request.get_json()['phone']
        venue.facebook_link = request.get_json()['facebook_link']

        for genre_id in genres:
            genre = Genre.query.get(genre_id)
            venue.genres.append(genre)
        db.session.add(venue)
        db.session.commit()
        body['id'] = venue.id
        body['name'] = venue.name

    except:
        print("Oops!", sys.exc_info(), "occured.")
        error = True
        db.session.rollback()

    finally:
        db.session.close()

    if error:
        flash('venue ' + venue_name + ' could not be listed.')
        abort(400)
    else:
        flash('venue ' + venue_name + ' was successfully listed!')

    return jsonify(body)
Ejemplo n.º 7
0
from models import storage
from models.city import City
from models.venue import Venue
from models.show import Show
from models.artist import Artist
from models.organizer import Organizer
#Create city
organizer = Organizer
city = City(city_name='Cali', country_name="Colombia")
city.save()

#create venue
venue = Venue(city_id=city.id,
              venue_name="Asilo",
              email="*****@*****.**",
              address="Calle del cartucho",
              capacity=150)
venue.save()
#create show
show = Show(venue_id=venue.id, price_tikets=25000)
#Create artist
artist = Artist(artist_name="Ponkeys",
                genre_artist="Funk",
                email="*****@*****.**")
artist.save()
print(venue)
print(show)
print(artist)
print(show.org_id)
Ejemplo n.º 8
0
def seed_db():
    genre_objs = [Genre(name=genre) for genre in genres]
    artist_objs = [Artist(**artist) for artist in artists]
    venue_objs = [Venue(**venue) for venue in venues]

    try:
        db.session.add_all(genre_objs)
        db.session.add_all(artist_objs)
        db.session.add_all(venue_objs)
        db.session.commit()

        # genre ids
        genre_ids = {}
        for genre in genre_objs:
            genre_ids.update({genre.name: genre.id})

        # artist ids
        artist1_id = artist_objs[0].id
        artist2_id = artist_objs[1].id
        artist3_id = artist_objs[2].id

        # venue ids
        venue1_id = venue_objs[0].id
        venue2_id = venue_objs[1].id
        venue3_id = venue_objs[2].id

        # add artist genres
        artists_genres = [
            ArtistGenre(artist_id=artist1_id, genre_id=genre_ids["Rock n Roll"]),
            ArtistGenre(artist_id=artist2_id, genre_id=genre_ids["Jazz"]),
            ArtistGenre(artist_id=artist3_id, genre_id=genre_ids["Jazz"]),
            ArtistGenre(artist_id=artist3_id, genre_id=genre_ids["Classical"])
        ]
        db.session.add_all(artists_genres)

        # add venue genres
        venues_genres = [
            VenueGenre(venue_id=venue1_id, genre_id=genre_ids["Jazz"]),
            VenueGenre(venue_id=venue1_id, genre_id=genre_ids["Reggae"]),
            VenueGenre(venue_id=venue1_id, genre_id=genre_ids["Swing"]),
            VenueGenre(venue_id=venue1_id, genre_id=genre_ids["Classical"]),
            VenueGenre(venue_id=venue1_id, genre_id=genre_ids["Folk"]),

            VenueGenre(venue_id=venue2_id, genre_id=genre_ids["Classical"]),
            VenueGenre(venue_id=venue2_id, genre_id=genre_ids["R&B"]),
            VenueGenre(venue_id=venue2_id, genre_id=genre_ids["Hip-Hop"]),

            VenueGenre(venue_id=venue3_id, genre_id=genre_ids["Rock n Roll"]),
            VenueGenre(venue_id=venue3_id, genre_id=genre_ids["Jazz"]),
            VenueGenre(venue_id=venue3_id, genre_id=genre_ids["Classical"]),
            VenueGenre(venue_id=venue3_id, genre_id=genre_ids["Folk"]),
        ]
        db.session.add_all(venues_genres)

        # add shows

        shows = [
            {'artist_id': artist1_id, 'venue_id': venue3_id,
             'start_time': '2019-06-15T23:00:00.000Z'},
            {'artist_id': artist3_id, 'venue_id': venue3_id,
             'start_time': '2035-04-01T20:00:00.000Z'},
            {'artist_id': artist3_id, 'venue_id': venue3_id,
             'start_time': '2035-04-08T20:00:00.000Z'},
            {'artist_id': artist3_id, 'venue_id': venue3_id,
             'start_time': '2035-04-15T20:00:00.000Z'},
            {'venue_id': venue1_id, 'artist_id': artist1_id,
             'start_time': '2019-05-21T21:30:00.000Z'},
            {'venue_id': venue3_id, 'artist_id': artist2_id,
             'start_time': '2019-06-15T23:00:00.000Z'},
            {'venue_id': venue3_id, 'artist_id': artist3_id,
             'start_time': '2035-04-01T20:00:00.000Z'},
            {'venue_id': venue3_id, 'artist_id': artist3_id,
             'start_time': '2035-04-08T20:00:00.000Z'},
            {'venue_id': venue3_id, 'artist_id': artist3_id,
             'start_time': '2035-04-15T20:00:00.000Z'},
        ]
        show_objs = [Show(**show) for show in shows]
        db.session.add_all(show_objs)
        db.session.commit()

    except:
        db.session.rollback()
        print(sys.exc_info())
    finally:
        db.session.close()
Ejemplo n.º 9
0
my_hs_garage_band = Band(name="My Band From High School")

phish.shows.extend([phish_12_31_95, phish_11_28_03])
dead.shows.extend([dead_5_8_77, dead_venetta, dead_1_7_79])
person1.shows.extend([dead_5_8_77, phish_12_31_95, phish_11_28_03])
person2.shows.extend([dead_venetta, dead_5_8_77])
person3.shows.append(dead_venetta)

# Cities
uniondale = City(name="Uniondale, NY")
veneta = City(name="Veneta, OR")
nyc = City(name="New York, NY")
ithaca = City(name="Ithaca, NY")

# Venues
nassau_coliseum = Venue(name='Nassau Veterans Memorial Coliseum',
                        capacity=17686)
springfield_creamery = Venue(name='Springfield Creamery', capacity=30000)
msg = Venue(name="Madison Square Garden", capacity=20789)
barton_hall = Venue(name="Barton Hall", capacity=5000)
brooklyn_bowl = Venue(name="Brooklyn Bowl", capacity=600)

nassau_coliseum.city = uniondale
springfield_creamery.city = veneta
msg.city = nyc
barton_hall.city = ithaca
brooklyn_bowl.city = nyc

phish_11_28_03.venue = nassau_coliseum
phish_12_31_95.venue = msg
dead_5_8_77.venue = barton_hall
dead_venetta.venue = springfield_creamery