Ejemplo n.º 1
0
def newArtists():
    form = NewArtistForm()
    if form.validate_on_submit():
        flash('Artist info entered for name {}'.format(
            form.name.data, form.hometown.data, form.description.data))
        a = Artist(name=form.name.data, hometown=form.hometown.data)
        db.session.add(a)
        db.session.commit()
        return redirect(url_for("artists"))
    return render_template('newArtists.html',  title='New Artists', form=form)
Ejemplo n.º 2
0
def new_artist():
    form = NewArtistForm()
    if form.validate_on_submit():
        flash_message = 'New Artist Created: {}'\
            .format(form.name.data)
        flash(flash_message)
        a = Artist(name=form.name.data, hometown=form.hometown.data, description=form.description.data)
        db.session.add(a)
        db.session.commit()
        return redirect(url_for('artists'))
    return render_template('new_artist.html', title="New Artist", form=form)
Ejemplo n.º 3
0
def new_artist():
    form = NewArtistForm()

    if form.validate_on_submit():
        flash('Artist Created: ' + form.name.data)
        artist = Artist(name=form.name.data.strip(),
                        hometown=form.hometown.data.strip(),
                        bio=form.bio.data.strip())
        db.session.add(artist)
        db.session.commit()

        return redirect(url_for('list_artists'))

    return render_template('new_artist.html', title='New Artist', form=form)
Ejemplo n.º 4
0
def new_artist():
    form = NewArtistForm()
    if form.validate_on_submit():
        if Artist.query.filter_by(name=form.name.data).count() > 0:
            flash('Error! Artist ' + form.name.data +
                  ' has already been created!')
            return redirect(url_for('new_artist'))
        else:
            form_artist = Artist(name=form.name.data,
                                 hometown=form.hometown.data,
                                 description=form.description.data)
            db.session.add(form_artist)
            db.session.commit()
            flash('New Artist Successfully Submitted!')
            return render_template("artist.html", artist=form_artist)
    return render_template("new_artist_form.html",
                           title='New Artist',
                           form=form)
Ejemplo n.º 5
0
def newartist():

    form = NewArtistForm()

    if form.validate_on_submit():
        flash('New Artist added: {}'.format(form.name.data))
        flash('Hometown: {}'.format(form.hometown.data))
        flash('Description: {}'.format(form.description.data))
        return render_template(
            '/artist.html',
            name=form.name.data,
            hometown=form.hometown.data,
            description=form.description.data,
        )

    return render_template(
        'newartist.html',
        title="New Artist",
        form=form,
    )
Ejemplo n.º 6
0
def create():
    form = NewArtistForm()

    if form.validate_on_submit():
        flash('Thank you, a new artist has been created.')
        info = {}
        info["name"] = form.name.data
        info["genre"] = form.genre.data
        info["hometown"] = form.hometown.data
        info["bio"] = form.bio.data

        a = Artist(name=form.name.data,
                   genre=form.genre.data,
                   hometown=form.hometown.data,
                   bio=form.bio.data)
        db.session.add(a)
        db.session.commit()
        return redirect('/artists')
    return render_template('newArtist.html',
                           title='Create New Artist',
                           form=form)
Ejemplo n.º 7
0
def signUp():
    if current_user.is_authenticated:
        return redirect(url_for('index'))
    form = NewArtistForm()
    if form.validate_on_submit():
        # make new artist
        location = Location.objects(city=form.city.data, state=form.state.data).first()
        if location is None:
            location = Location(city=form.city.data, state=form.state.data, zip_code=form.zip.data)
            location.save(cascade=True)
        mediaLinks = []
        if form.facebook.data != "":
            mediaLinks.append(form.facebook.data)
        if form.youtube.data != "":
            mediaLinks.append(form.youtube.data)
        if form.spotify.data != "":
            mediaLinks.append(form.spotify.data)
        newArtist = Artist(email=form.email.data, name=form.bandName.data, description=form.description.data,
                           media_links=mediaLinks, location=location, genre=form.genre.data, image=form.image.data)
        newArtist.set_password(form.password.data)
        newArtist.save(cascade=True)
        return redirect(url_for('logIn'))  # probably want to send to artist page once that exists
    return render_template('signUp.html', form=form)