예제 #1
0
def delete_artist():
    artist = str(request.form["artistid"])

    # Don't delete an artist if they have any murals
    murals = firebase.get('/', 'murals')
    for key in murals:
        if murals[key]["Artist"] == artist:
            flash("Cannot delete an artist with existing murals!")
            return redirect(url_for('all_artists'), code=302)

    firebase.delete('/artists', artist)
    return redirect(url_for('all_artists'), code=302)
예제 #2
0
def edit_artist():
    form = EditArtist()
    artist_id = str(request.args["artists"])
    artists = firebase.get('/', 'artists')
    artist = artists[artist_id]
    if form.validate_on_submit():
        put_data = {'name': form.name.data,
                    'city': form.city.data,
                    'bio': form.bio.data,
                    'link': form.link.data,
                    'uuid': str(artist_id)}
        firebase.delete('/artists', str(artist_id))
        firebase.put('/artists', artist_id, put_data)
        return redirect(url_for('all_artists'), code=302)
    return render_template('edit_artist.html', form=form, artist=artist)
예제 #3
0
def delete_mural():
    # reindex all the murals
    murals = firebase.get('/', 'murals')
    key = str(request.form["muralid"])
    removed_index = murals[key]["Index"]

    # if a mural's index is > removed_index, decrement the index
    for m in murals:
        if murals[m]["Index"] > removed_index:
            murals[m]["Index"] -= 1

    # remove the mural
    if key in murals: del murals[key]

    # update firebase
    firebase.delete('/murals', key)
    for id in murals:
        firebase.put('/murals', id, murals[id])

    return redirect(url_for('all_murals'), code=302)
예제 #4
0
def edit_mural():
    edit_form = EditMural()
    mural_id = str(request.args["muralid"])
    murals = firebase.get('/', 'murals')
    mural = murals[mural_id]
    artists = firebase.get('/', 'artists')
    sorted_artists = []
    for a in artists:
        sorted_artists.append((artists[a]["uuid"], artists[a]["name"]))
    sorted_artists = sorted(sorted_artists, key=lambda x: x[1])
    edit_form.artist.choices = sorted_artists
    if edit_form.validate_on_submit():
        put_data = {'Photo': edit_form.photo.data, 'Lat': edit_form.lat.data,
                   'Long': edit_form.longitude.data, 'Artist': edit_form.artist.data,
                   'Title': edit_form.title.data, 'Month': edit_form.month.data,
                   'Year': edit_form.year.data, 'Description': edit_form.description.data,
                   'Medium': edit_form.medium.data, 'uuid': str(mural_id),
                   'Index': mural["Index"]}
        firebase.delete('/murals', str(mural_id))
        firebase.put('/murals', mural_id, put_data)
        return redirect(url_for('all_murals'), code=302)
    return render_template('edit_mural.html', form=edit_form, mural=mural, murals=murals, muralid=mural_id)