def post(self): artistKeyString = self.request.get('editArtistKey') artistID = int(artistKeyString) firstName = self.request.get('editFirstName') lastName = self.request.get('editLastName') biography = self.request.get('editBiography') photoName = self.request.get('editPhotoName') #get the photo specified by the user photo = File.query(File.file_name == photoName.upper()).get() #get the artist based on the key and update all fields artist = Artist.get_by_id(artistID) artist.biography = biography artist.firstName = firstName artist.lastName = lastName artist.picture = photo.key artist.uploaded_by = users.get_current_user() artist.put() artist.add_to_search_index() message = "Successfully updated artist record: " + artist.firstName + " " + artist.lastName self.response.write(message)
def post(self): artistKeyString = self.request.get('editArtistKey') artistID = int(artistKeyString) firstName = self.request.get('editFirstName') lastName = self.request.get('editLastName') biography = self.request.get('editBiography') photoName = self.request.get('editPhotoName') #get the photo specified by the user photo = File.query(File.file_name==photoName.upper()).get() #get the artist based on the key and update all fields artist = Artist.get_by_id(artistID) artist.biography=biography artist.firstName=firstName artist.lastName=lastName artist.picture=photo.key artist.uploaded_by=users.get_current_user() artist.put() artist.add_to_search_index() message = "Successfully updated artist record: " + artist.firstName + " " + artist.lastName self.response.write(message)
def delete_artist(artist_id): print("delete") artist = Artist.get_by_id(artist_id) artist_name = artist.name result = artist.delete_from_db() if result["error"]: flash("An error occurred. Artist " + artist_name + " could not be deleted.") abort(500) flash("Artist " + artist_name + " was successfully deleted!") return render_template("pages/home.html")
def post(self): artistKeyString = self.request.get('deleteArtistKey') #generate message artist = Artist.get_by_id(int(artistKeyString)) artist.remove_from_search_index() message = "Successfully deleted artist: " + artist.firstName + " " + artist.lastName #delete artist artistKey = artist.key artistKey.delete() self.response.write(message)
def post(self): artistKeyString = self.request.get('deleteArtistKey') #generate message artist = Artist.get_by_id(int(artistKeyString)) artist.remove_from_search_index() message = "Successfully deleted artist: " + artist.firstName + " " + artist.lastName #delete artist artistKey = artist.key artistKey.delete() self.response.write(message)
def edit_artist(artist_id): artist = Artist.get_by_id(artist_id) form = ArtistForm(request.form, obj=artist) form.genres.process_data(artist.genres) form.seeking_venue.process_data(artist.seeking_venue) return render_template("forms/edit_artist.html", form=form, artist=artist)