Пример #1
0
def reset_db():
    flash("Resetting database: deleting old data and repopulating with dummy data")
    # clear all data from all tables
    meta = db.metadata
    for table in reversed(meta.sorted_tables):
        print('Clear table {}'.format(table))
        db.session.execute(table.delete())
    db.session.commit()
    artist1 = Artist(name='Shane Fox', hometown='Delmar', description='He rocks')
    artist2 = Artist(name='Doug Turnbull', hometown='Ithaca', description='He always rocks')
    artist3 = Artist(name='John Doe', hometown='Cortland', description='He never rocks')
    db.session.add_all([artist1, artist2, artist3])
    db.session.commit()
    d1 = datetime(2019, 10, 19, 20, 0)
    event1 = Event(title='Jam Fest', date=d1, venueID=1)
    d2 = datetime(2019, 11, 15, 21, 0)
    event2 = Event(title='Turn up', date=d2, venueID=1)
    d3 = datetime(2019, 12, 5, 19, 0)
    event3 = Event(title='Fun Time', date=d3, venueID=3)
    db.session.add_all([event1, event2, event3])
    db.session.commit()
    venue1 = Venue(title='The Haunt', city='Ithaca', state='New York', capacity=100)
    venue2 = Venue(title='Moonies', city='Ithaca', state= 'New York', capacity=200)
    venue3 = Venue(title='Silky Jones', city='Ithaca', state='New York', capacity=300)
    db.session.add_all([venue1, venue2, venue3])
    db.session.commit()
    a2e1 = ArtistToEvent(artist=artist1, event=event1)
    a2e2 = ArtistToEvent(artist=artist2, event=event1)
    a2e3 = ArtistToEvent(artist=artist3, event=event3)
    a2e4 = ArtistToEvent(artist=artist1, event=event3)
    db.session.add_all([a2e1, a2e2, a2e3, a2e4])
    db.session.commit()
    return render_template('index.html', title='Home')
Пример #2
0
def venues():
    data = Venue.get_areas_with_venue()
    for d in data:
        venues = Venue.get_venues_by_area(d['city'], d['state'])
        d['venues'] = [venue.summary for venue in venues]

    return render_template('pages/venues.html', areas=data)
Пример #3
0
def post():
    # 获取经纬坐标
    coordinate_lng = request.form.get('coordinate_lng', '')
    coordinate_lat = request.form.get('coordinate_lat', '')
    if coordinate_lng and coordinate_lat:
        # 先从数据库中 通过坐标获取地点,如果有直接返回,没有则保存
        venue = db.session.query(Venue).filter(
            Venue.coordinate_lng == coordinate_lng,
            Venue.coordinate_lat == coordinate_lat).first()

        if venue:
            data = {'id': venue.id}
            return jsonify({'code': 1, 'result': data})
        else:
            try:
                venue = Venue()
                venue.name = request.form.get('name', '')
                venue.address = request.form.get('address', '')
                venue.coordinate_lng = coordinate_lng
                venue.coordinate_lat = coordinate_lat
                venue.category = request.form.get('category', '')
                venue.link_man_mobile = request.form.get('link_man_mobile', '')

                venue = Venue().add(venue)
                data = {'id': venue.id}
                return jsonify({'code': 1, 'result': data})
            except Exception, e:
                current_app.logger.error(str(e))
                e_msg = ' venue save error '
                return jsonify({'code': 0, 'error': e_msg})
Пример #4
0
def reset_db():
    flash(
        "Resetting database: deleting old data and repopulating with dummy data"
    )
    # clear all data from all tables
    meta = db.metadata
    for table in reversed(meta.sorted_tables):
        print('Clear table {}'.format(table))
        db.session.execute(table.delete())
    db.session.commit()
    default_venues = [
        Venue(name='Stewart Park',
              address='1 James L Gibbs Dr, Ithaca, NY 14850'),
        Venue(name='The Haunt', address='702 Willow Ave, Ithaca, NY 14850'),
        Venue(name='Ithaca College', address='953 Danby Rd, Ithaca, NY 14850')
    ]
    dates = [
        datetime(2018, 9, 21, 20, 0, 0),
        datetime(2018, 3, 7, 20, 0, 0),
        datetime(2034, 5, 18, 21, 0, 0)
    ]
    default_events = [
        Event(name='Cayuga Sound Festival', time=dates[0], venue_id=1),
        Event(name='Matt and Kim Concert', time=dates[1], venue_id=2),
        Event(name='Young The Giant Concert', time=dates[2], venue_id=2),
        Event(name='Jon Bellion Concert', time=dates[1], venue_id=3)
    ]
    default_artists = [
        Artist(name='X Ambassadors',
               hometown='Ithaca, NY',
               description='The X Ambassadors description'),
        Artist(name='Young The Giant',
               hometown='Irvine, CA',
               description='Young The Giant description'),
        Artist(name='Matt and Kim',
               hometown='Boston, MA',
               description='Matt and Kim description'),
        Artist(name='Roots',
               hometown='Philadelphia, PA',
               description='Roots description'),
        Artist(name='Jon Bellion',
               hometown='Smithtown, NY',
               description='Jon Bellion description')
    ]
    default_a_to_e = [
        ArtistToEvent(artist_id=1, event_id=1),
        ArtistToEvent(artist_id=2, event_id=1),
        ArtistToEvent(artist_id=3, event_id=1),
        ArtistToEvent(artist_id=3, event_id=2),
        ArtistToEvent(artist_id=2, event_id=3),
        ArtistToEvent(artist_id=4, event_id=1),
        ArtistToEvent(artist_id=5, event_id=4)
    ]
    db.session.add_all(default_artists)
    db.session.add_all(default_venues)
    db.session.add_all(default_events)
    db.session.add_all(default_a_to_e)
    db.session.commit()
    return redirect(url_for('index'))
Пример #5
0
def create_venue():
    data = request.get_json(force=True)

    validate(data, post_create_venue_schema)

    venue = Venue(**data)

    dao_create_venue(venue)
    return jsonify(venue.serialize()), 201
Пример #6
0
    def test_One(self):

        tperformer = add_performer(bandname ="testband" )
        tvenue = Venue(name ="Stereo")
        tvenue.save()
        my_datetime = timezone.make_aware(datetime.now(), timezone.get_current_timezone())
        event_one = Event(time =my_datetime,media='https://www.youtube.com/watch?v=eh7lp9umG2I',venue=tvenue,performer=tperformer,no_tickets=-1)
        event_one.save()
        self.assertEqual((event_one.no_tickets >=0),True)
Пример #7
0
    def test_performer_has_no_event(self):

        p = add_performer("Isosceles")
        my_datetime = timezone.make_aware(datetime.now(), timezone.get_current_timezone())
        tm = "https://www.youtube.com/watch?v=uH3zT03DkFQ"
        tvenue = Venue(name ="Stereo")
        tvenue.save()
        event_test = add_event(my_datetime,tm,tvenue,p)
        response = self.client.get(reverse('index'))
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "Stereo")
Пример #8
0
def populate_db():
    c1 = City(name='Ithaca, NY')
    c2 = City(name='Binghamton, NY')
    c3 = City(name='Syracuse, NY')
    c4 = City(name='Rochester, NY')
    db.session.add_all([c1, c2, c3, c4])
    db.session.commit()
    a1 = Artist(name="Driftwood", description="Folk Rock", cityID=c2.id)
    a2 = Artist(name="Quail", description="Funk and Brass", cityID=c1.id)
    a3 = Artist(name="VeeDaBee", description="Rock Band", cityID=c1.id)
    a4 = Artist(name="Danielle Ponder", description="Soul", cityID=c4.id)
    db.session.add_all([a1, a2, a3, a4])
    db.session.commit()
    v1 = Venue(name='The Haunt', cityID=c2.id)
    v2 = Venue(name='State Theater', cityID=c1.id)
    v3 = Venue(name='Stewart Park', cityID=c1.id)
    v4 = Venue(name='University', cityID=c2.id)
    v5 = Venue(name='Oncenter', cityID=c3.id)
    db.session.add_all([v1, v2, v3, v4, v5])
    db.session.commit()
    e1 = Event(name='Ithaca Porchfest',
               time=datetime(2020, 11, 5, 20, 00),
               venueID=v3.id)
    e2 = Event(name='2020 Tour',
               time=datetime(2020, 10, 20, 18, 00),
               venueID=v5.id)
    e3 = Event(name='Anniversary Concert',
               time=datetime(2020, 10, 20, 19, 00),
               venueID=v1.id)
    e4 = Event(name='2020 Tour',
               time=datetime(2020, 10, 29, 18, 00),
               venueID=v2.id)
    e5 = Event(name='2020 Tour',
               time=datetime(2020, 10, 20, 12, 00),
               venueID=v4.id)
    db.session.add_all([e1, e2, e3, e4, e5])
    db.session.commit()
    x1 = ArtistToEvent(artistID=a1.id, eventID=e3.id)
    x2 = ArtistToEvent(artistID=a2.id, eventID=e3.id)
    x3 = ArtistToEvent(artistID=a1.id, eventID=e1.id)
    x4 = ArtistToEvent(artistID=a3.id, eventID=e4.id)
    x5 = ArtistToEvent(artistID=a4.id, eventID=e5.id)
    x6 = ArtistToEvent(artistID=a3.id, eventID=e2.id)
    db.session.add_all([x1, x2, x3, x4, x5, x6])
    db.session.commit()
    u1 = User(username='******',
              email=('*****@*****.**'),
              password_hash='Password')
    db.session.add(u1)
    db.session.commit()
    return render_template('base.html', title='Populate DB')
Пример #9
0
def populate_db():
    b1 = Bard(name="Marillion",
              description="I'm drunk but talented and know many sad lays.")
    b1.set_password("Marillion")
    b2 = Bard(
        name="Tom O Sevenstrings",
        description="No one plays quite like me. I know hundreds of songs.")
    b3 = Bard(name="The Blue Bard",
              description="My hair is bright blue and I know a tune or two.")
    b4 = Bard(
        name="Symon Silvertongue",
        description=
        "I am not merely a reciter of tunes. I am an accomplished lyricist.")
    b5 = Bard(name="Shylock the Shy", description="I prefer to play alone.")
    db.session.add_all([b1, b2, b3, b4, b5])
    db.session.commit()
    e1 = Event(eventname="The Great Tourney",
               venueID=1,
               startTime=datetime(1604, 3, 5))
    e2 = Event(eventname="Bilbo's 111th Birthday",
               venueID=2,
               startTime=datetime(3001, 9, 22))
    e3 = Event(eventname="Frodo's Birthday",
               venueID=2,
               startTime=datetime(3001, 9, 22))
    e4 = Event(eventname="Joffrey's Wedding",
               venueID=1,
               startTime=datetime(1207, 3, 9))
    e5 = Event(eventname="Manwe's Great Feast",
               venueID=3,
               startTime=datetime(1006, 3, 19))
    db.session.add_all([e1, e2, e3, e4, e5])
    db.session.commit()
    be1 = BardToEvent(bardID=b1.id, eventID=e1.id)
    be2 = BardToEvent(bardID=b1.id, eventID=e5.id)
    be3 = BardToEvent(bardID=b2.id, eventID=e1.id)
    be4 = BardToEvent(bardID=b4.id, eventID=e1.id)
    be5 = BardToEvent(bardID=b3.id, eventID=e4.id)
    be6 = BardToEvent(bardID=b2.id, eventID=e3.id)
    be7 = BardToEvent(bardID=b3.id, eventID=e5.id)
    db.session.add_all([be1, be2, be3, be4, be5, be6, be7])
    db.session.commit()
    v1 = Venue(village="King's Landing", kingdom="Westeros")
    v2 = Venue(village="The Shire", kingdom="Middle Earth")
    v3 = Venue(village="Valinor", kingdom="Arda")
    db.session.add_all([v1, v2, v3])
    db.session.commit()
    return render_template('base.html', title='Populate DB')
Пример #10
0
def create_event():
    """Render the view that allows a user to create an event"""
    event = None
    form = CreateEventForm()
    if form.validate_on_submit():
        venue = Venue.query.filter_by(address=form.address.data).first()
        if venue is None:  # venue not already in db, need to add it
            venue_data = form.data
            venue_data["name"] = venue_data["venue_name"]
            venue_data["state"] = CreateEventForm.convert_choice_to_value(
                form.state.data, "STATES")
            venue = Venue.create(**venue_data)
        event_type = EventType.query.get(form.event_type.data)
        event_category = EventCategory.query.get(form.category.data)
        start_time = CreateEventForm.convert_choice_to_value(
            form.start_time.data, "TIMES")
        end_time = CreateEventForm.convert_choice_to_value(
            form.end_time.data, "TIMES")
        event = Event(
            title=form.title.data,
            start_datetime=datetime.combine(form.start_date.data, start_time),
            end_datetime=datetime.combine(form.end_date.data, end_time),
            venue=venue,
            event_type=event_type,
            event_category=event_category,
            user=current_user._get_current_object(),
        )
        db.session.commit()
        return redirect(url_for("events.event_details", id=event.id))
    return render_template("events/create_event.html", form=form, event=event)
Пример #11
0
def create_venue():
    '''create new venue'''
    form = VenueForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            venue = Venue(
                name=form.name.data,
                genres=",".join(form.genres.data),
                address=form.address.data,
                city=form.city.data,
                state=form.state.data,
                phone=form.phone.data,
                website=form.website.data,
                facebook_link=form.facebook_link.data,
                seeking_talent=form.seeking_talent.data,
                seeking_description=form.seeking_description.data,
                image_link=form.image_link.data
            )
            db.session.add(venue)
            db.session.commit()
            flash('venue ' + venue.name +
                  ' was successfully listed!')
            return redirect(url_for('venues'))
        else:
            flash("Found errors: {}".format(form.errors))
    return render_template('forms/new_venue.html', form=form)
Пример #12
0
def addVenue():
    form = newVenueForm()
    if form.validate_on_submit():
        flash('Venue submitted with name="{}" and location="{}"'.format(
            form.venueName.data, form.location.data))
        venue = Venue(name=form.venueName.data, location=form.location.data)
        db.session.add(venue)
        db.session.commit()
        return redirect(url_for('index'))
    return render_template('addVenue.html', title='Add Venue', form=form)
Пример #13
0
def organization_venues_create(auth_user, organization):
    with WriteSession() as session:
        with session.no_autoflush:
            org_venue = Venue.from_request(request.json)
            if session.query(Venue).filter(Venue.organization == organization, Venue.slug == org_venue.slug).first():
                abort(400, {'code': 400, 'message': 'That venue already exists on this organization', 'data': {'venue': org_venue.to_json()}})
            org_venue.organization = organization
            session.add(org_venue)
            session.commit()
            return organization.to_json(with_relationships={'venues': {'venue': None}})['venues']
Пример #14
0
 def create_venue(cls, address="25 Ford Ave"):
     """Return an instance of the Venue class."""
     venue = Venue(
         name="ABC Venue",
         address=address,
         city="Scottsdale",
         state="AZ",
         zip_code="12345",
     )
     return venue
Пример #15
0
def new_venue():
    form = NewVenueForm()
    if form.validate_on_submit():
        flash_message = 'New Venue Created: {}'\
            .format(form.title.data)
        flash(flash_message)
        v = Venue(title=form.title.data, city=form.city.data, state=form.state.data, capacity=form.capacity.data)
        db.session.add(v)
        db.session.commit()
        return redirect(url_for('new_venue'))
    return render_template('new_venue.html', title="New Venue", form=form)
Пример #16
0
def search_venues():
    search_term = request.form.get('search_term', '')
    venues = Venue.get_venues_by_partial_name(search_term)
    response = {
        'count': len(venues),
        'data': [venue.summary for venue in venues]
    }

    return render_template('pages/search_venues.html',
                           results=response,
                           search_term=search_term)
Пример #17
0
def new_venue():
    form = NewVenueForm()
    if form.validate_on_submit():
        if Venue.query.filter_by(address=form.address.data).count() > 0:
            flash('Venue with that address has already been created!')
            return redirect(url_for('new_venue'))
        form_venue = Venue(name=form.name.data, address=form.address.data)
        db.session.add(form_venue)
        db.session.commit()
        flash('New Venue Successfully Submitted!')
        return redirect(url_for('index'))
    return render_template('new_venue_form.html', title='New Venue', form=form)
Пример #18
0
def venue():
    form = VenueForm()
    if form.validate_on_submit():
        venue = Venue(village=form.village.data, kingdom=form.kingdom.data)
        db.session.add(venue)
        db.session.commit()

        flash('Created new Venue: {}'.format(form.village.data,
                                             form.kingdom.data))
        final_form = VenueForm()
        render_template('venue.html', title='New Venue', form=final_form)

    return render_template('venue.html', title='New Venue', form=form)
Пример #19
0
def createNewVenue():
    form = VenueForm()
    if form.validate_on_submit():
        flash('New venue requested for artist {}'.format(form.venueName.data))
        my_venue = Venue(name=form.venueName.data,
                         date=form.date.data,
                         location=form.address.data,
                         tickets=form.tickets.data)
        db.session.add(my_venue)
        db.session.commit()
        flash('New venue created.')
        return redirect(url_for('listOfArtists'))
    return render_template('newVenue.html', title='newVenue', form=form)
Пример #20
0
    def add_events(self):
        """Add fake event data to the database."""
        print("Add events...")
        user_count = User.query.count()
        category_count = EventCategory.query.count()
        type_count = EventType.query.count()
        role = Role.query.filter_by(name="Event Organizer").first()
        users = User.query.filter_by(role=role).all()
        for index in range(self.num_events):
            user = random.choice(users)

            event_type = EventType.query.get(random.randint(1, type_count))
            category, location = random.choice(CATEGORIES_AND_LOCATIONS)
            event_category = EventCategory.query.filter_by(
                name=category).first()
            venue = Venue(
                name=self.faker.company(),
                address=self.faker.street_address(),
                city=location[0],
                state=location[1],
                zip_code=self.faker.zipcode(),
            )
            random_start_date = datetime.now() + timedelta(
                days=random.randint(1, 90))
            start_date = self.faker.date_between(
                start_date=random_start_date,
                end_date=random_start_date + timedelta(days=30),
            )
            string_time = random.choice(TIMES[:40])[1]
            start_time = datetime.strptime(string_time, TIME_FORMAT)
            start_datetime = datetime.combine(start_date, start_time.time())

            event = Event(
                title=self.faker.company() +
                random.choice([" Party", " Gala"]),
                start_datetime=start_datetime,
                end_datetime=start_datetime + timedelta(days=1),
                attendees=random.choice(PEOPLE_RANGES[1:])[1],
                male_to_female="50-50",
                description=self.faker.text(),
                pitch=self.faker.text(),
                published=True,
                user=user,
                venue=venue,
                event_type=event_type,
                event_category=event_category,
            )
            image = self.get_random_event_image(event)
            event.image = image
            db.session.add(event)
        db.session.commit()
Пример #21
0
def populateDb():
    a1 = Artist(
        name="Feed Me Jack",
        hometown="Oakland",
        bio=
        "For about five years when they were active (from 2011 until 2016) they had released 4 eps on their own (e.g. via Bandcamp), and no other info around them actually."
    )
    a2 = Artist(
        name="Space Carnival",
        hometown="Oneonta",
        bio="High energy disco/funk band that provides many favorited covers")
    a3 = Artist(
        name="Peach Pit",
        hometown="Vancouver",
        bio=
        "The Canadian band is led by singer and rhythm guitarist Neil Smith, lead guitarist Christopher Vanderkooy, bassist Peter Wilton, and drummer Mikey Pascuzzi. ... The band's music videos are produced by videographer Lester Lyons-Hookham."
    )
    v1 = Venue(name="The Haunt", location="Ithaca")
    v2 = Venue(name="Madison Square Garden", location="NYC")

    db.session.add_all([a1, a2, a3, v1, v2])
    db.session.commit()
    return "DB populated"
Пример #22
0
def new_venue():
    form = NewVenueForm()

    if form.validate_on_submit():
        flash('Venue Created: ' + form.name.data)
        venue = Venue(name=form.name.data.strip(),
                      city=form.city.data.strip(),
                      country=form.country.data.strip())
        db.session.add(venue)
        db.session.commit()

        return redirect(url_for('list_artists'))

    return render_template('new_venue.html', title='New Venue', form=form)
Пример #23
0
def create_venue_submission():
    error = False
    data = request.form

    try:
        venue = Venue()
        venue.name = data['name']
        venue.city = data['city']
        venue.state = data['state']
        venue.address = data['address']
        venue.phone = data.get('phone', '')
        venue.facebook_link = data.get('facebook_link', '')
        venue.genres = [
            VenueGenres(genre=GenreEnum[genre])
            for genre in data.getlist('genres')
        ]
        db.session.add(venue)
        db.session.commit()
    except:
        error = True
        db.session.rollback()
    finally:
        data = venue.to_dict()
        db.session.close()

    if not error:
        # on successful db insert, flash success
        flash(f'Venue {data["name"]} was successfully listed!',
              'alert-success')
    else:
        # on unsuccessful db insert, flash an error
        flash(
            f'An error occurred. Venue {data["name"]} could not be listed. \
              Does the venue already exist?', 'alert-danger')

    return render_template('pages/home.html')
Пример #24
0
def populate_db():
    a1 = Artist(name='Bastille', hometown="London")
    a2 = Artist(name="Imagine Dragons", hometown="Las Vegas")
    a3 = Artist(name="Of Monsters and Men", hometown="Reyjavik")
    v1 = Venue(name="State Theater")  #location="Downtown Ithaca")
    v2 = Venue(name="A&ECenter")  #location="IC")
    v3 = Venue(name="Stewart Park")  #location="Ithaca")
    v4 = Venue(name="ICSquare")  #location="IC")
    db.session.add_all([a1, a2, a3, v1, v2, v3, v4])
    db.session.commit()

    e1 = Event(name="IC Presents",
               venueID=v4.id,
               date=datetime(2020, 8, 6, 17, 30))
    e2 = Event(name="Rock the Park",
               venueID=v3.id,
               date=datetime(2020, 8, 6, 17, 30))
    e3 = Event(name="A&E Concerts",
               venueID=v2.id,
               date=datetime(2020, 8, 6, 17, 30))
    e4 = Event(name="State Theater Jam",
               venueID=v1.id,
               date=datetime(2020, 8, 6, 17, 30))
    e5 = Event(name="Music over Ithaca",
               venueID=v3.id,
               date=datetime(2020, 8, 6, 17, 30))
    db.session.add_all([e1, e2, e3, e4, e5])
    db.session.commit()

    AE1 = ArtistToEvent(eventID=e1.id, artistID=a3.id)
    AE2 = ArtistToEvent(eventID=e2.id, artistID=a2.id)
    AE3 = ArtistToEvent(eventID=e3.id, artistID=a1.id)
    AE4 = ArtistToEvent(eventID=e3.id, artistID=a2.id)
    db.session.add_all([AE1, AE2, AE3, AE4])
    db.session.commit()
    return "Database has been populated"
Пример #25
0
def create_venues():
    data = request.get_json(force=True)

    validate(data, post_create_venues_schema)

    venues = []
    for item in data:
        venue = Venue.query.filter(Venue.name == item['name']).first()
        if not venue:
            venue = Venue(**item)
            venues.append(venue)
            dao_create_venue(venue)
        else:
            current_app.logger.info('venue already exists: {}'.format(
                venue.name))
    return jsonify([v.serialize() for v in venues]), 201
Пример #26
0
    def setUp(self):
        # Called before every test
        db.create_all()

        # create test data
        self.user_musician = Profile(
            profile_id='2',
            email='*****@*****.**',
            username='******',
            profile_name=None,
            profile_description='Lorem ipsum dolor sit amet, '
            'consectetur adipiscing elit. '
            'Maecenas ac metus a erat facilisis dignissim.',
            location='London',
            rating=None,
            profile_image=None,
            block='0')
        self.user_venue = Profile(profile_id='1',
                                  email='*****@*****.**',
                                  username='******',
                                  profile_name=None,
                                  profile_description=None,
                                  location=None,
                                  rating=None,
                                  profile_image=None,
                                  block='0')
        self.genre = Genre(genre_id='1', genre_name='Rock')
        self.genre_profile = Profile_Genre(profile_id='2', genre_id='1')
        self.venue = Venue(venue_id='1',
                           venue_capacity=None,
                           venue_type=None,
                           profile_id='1')
        self.musician = Musician(musician_id='1',
                                 gender='1',
                                 profile_id='2',
                                 birthdate=None,
                                 availability=None,
                                 sc_id=None)
        self.user_venue.set_password('vizon')
        self.user_musician.set_password('bryan')
        db.session.add(self.user_musician)
        db.session.add(self.genre)
        db.session.add(self.genre_profile)
        db.session.add(self.user_venue)
        db.session.add(self.venue)
        db.session.add(self.musician)
        db.session.commit()
Пример #27
0
def newVenue():

    form = CreateVenueForm()
    if form.validate_on_submit():
        v = Venue.query.filter_by(name=form.name.data).first()
        if v is not None:
            flash('Venue already exists')
        else:
            w = Venue(name=form.name.data,
                      address=form.address.data,
                      city=form.city.data,
                      state=form.state.data)
            flash('New Venue Created!')
            db.session.add(w)
            db.session.commit()
            return redirect(url_for('Artists'))
    return render_template('newVenue.html', title="Create Venues", form=form)
Пример #28
0
def create_venue(old_id='1',
                 name='Head office',
                 address='10 London Street, N1 1NN',
                 directions='By bus: 100, 111, 123',
                 default=True):
    data = {
        'old_id': old_id,
        'name': name,
        'address': address,
        'directions': directions,
        'default': default
    }

    venue = Venue(**data)

    dao_create_venue(venue)
    return venue
Пример #29
0
def register():
    if current_user.is_authenticated:
        flash('You are logged in')
        return redirect(url_for('main.index', account='musicians'))
    form = SignupForm(request.form)
    if request.method == 'POST' and form.validate():
        user = Profile(username=form.username.data,
                       email=form.email.data,
                       profile_name=None,
                       profile_description=None,
                       profile_image=None,
                       location=None,
                       rating=None,
                       block=0)
        user.set_password(form.password.data)
        try:
            db.session.add(user)
            response = make_response(
                redirect(url_for('main.index', account='musicians')))
            response.set_cookie("username", form.username.data)
            user = Profile.query.filter_by(email=form.email.data).first()
            login_user(user)
            if form.option.data == 'm':
                user = Musician(gender=None,
                                profile_id=current_user.profile_id,
                                birthdate=None,
                                availability=None,
                                sc_id=None)
                db.session.add(user)
            else:
                user = Venue(venue_capacity=None,
                             profile_id=current_user.profile_id,
                             venue_type=None)
                db.session.add(user)
            db.session.commit()
            return response
        except IntegrityError:
            db.session.rollback()
            flash(
                'Unable to register {}. Please try again.'.format(
                    form.username.data), 'error')
            return redirect(url_for('main.index'))
    return render_template('register.html', form=form)
Пример #30
0
def new_venue():
    form = AddNewVenueForm()
    form.city.choices = [(t.id, t.name) for t in City.query.all()]

    if form.validate_on_submit():
        name = form.venue.data
        if Venue.query.filter_by(name=name).first() is not None:
            flash('Venue Already Documented')
            return redirect('/index')
        flash('New Venue Documented'.format(form.venue.data))

        city = form.city.data

        v1 = Venue(name=name, cityID=city)
        db.session.add(v1)
        db.session.commit()
        return redirect('/index')

    return render_template('new_venue.html', title='New Artist', form=form)
Пример #31
0
def create_venue_submission():
  # TODO: insert form data as a new Venue record in the db, instead
  # TODO: modify data to be the data object returned from db insertion
  form = VenueForm(request.form)

  try:
    new_venue = Venue(
      name=form.name.data,
      city=form.city.data,
      state=form.state.data,
      address=form.address.data,
      genres = form.genres.data,
      phone=form.phone.data,
      image_link=form.image_link.data,
      seeking_talent = form.seeking_talent.data,
      
      facebook_link=form.facebook_link.data,
      description = form.description.data,
      website = form.website.data
      
      
    )

    

    db.session.add(new_venue)
    db.session.commit()

    # on successful db insert, flash success
    flash('Venue ' + request.form['name'] + ' was successfully listed!')
  except:
    db.session.rollback()

    flash('An error occurred. Venue ' + data.name + ' could not be listed.')
  finally:
    db.session.close()

  
  # TODO: on unsuccessful db insert, flash an error instead.
  # e.g., flash('An error occurred. Venue ' + data.name + ' could not be listed.')
  # see: http://flask.pocoo.org/docs/1.0/patterns/flashing/
  return render_template('pages/home.html')
Пример #32
0
def create_venue_submission():
  try:
    data = request.form
    venue = Venue(
      name=data['name'],
      city=data['city'],
      state=data['state'],
      address=data['address'],
      phone=data['phone'],
      facebook_link=data['facebook_link'],
      genres=  ",".join(request.form.getlist('genres'))
      )
    db.session.add(venue)
    db.session.commit()
    print(venue)
    flash('Venue ' + data['name'] + ' was successfully listed!')
  except:
    flash('An error occurred. Venue ' + data['name'] + ' could not be listed.')
  finally:
    return render_template('pages/home.html')
Пример #33
0
    def create_action(kwargs={}):
        """Creates a Show"""

        try:
            if not kwargs:

                form = ShowForm(request.form)

                venue = Venue().query.filter(
                    Venue.name == form.venue_id.data).first()
                artist = Artist().query.filter(
                    Artist.name == form.artist_id.data).first()

                kwargs = {
                    "venue_id":
                    venue.id,
                    "artist_id":
                    artist.id,
                    "start_time":
                    datetime.datetime.strptime(
                        "{} {}".format(request.form.get('start_date', ''),
                                       request.form.get('start_time', '')),
                        "%b %d, %Y %H:%M %p")
                }

            model = Show(**kwargs)

            db.session.add(model)
            db.session.commit()

            flash('Show was successfully listed')

            return redirect(url_for('show.list_page', venue_id=model.id))

        except:

            flash('Whoops. Show could not be listed.')

            return redirect(url_for('show.create_form_page'))
Пример #34
0
# -*- coding: utf-8 -*-

from app.models import Venue, Event
from google.appengine.ext.db import *
from datetime import datetime, date, time, timedelta

now = datetime.now()
just_before = now - timedelta(hours=1)
just_after = now - timedelta(hours=1)
later = now + timedelta(days=1)
much_later = now + timedelta(days=5)

chalmers = Venue(
  name=u"Chalmers Tekniska Högskola",
  address=PostalAddress(u"Chalmersplatsen 1, Göteborg"),
)
chalmers.save()

kth = Venue(
  name=u"KTH",
  address=PostalAddress(u"SE-100 44 Stockholm"),
)
kth.save()

svenska_massan = Venue(
  name=u"Svenska Mässan",
  address=PostalAddress(u"Korsvägen Göteborg"),
)
svenska_massan.save()

ncpc = Event(