def addArtist(): if not checkLogin(): return redirect(url_for('showArtCatalog')) # There is no risk of error as the existence of login_session['user_id'] # was checked by checkLogin() user = login_session['user_id'] if request.method == 'POST': new_name = request.form['name'] new_information = request.form['information'] new_url = request.form['url'] new_artist = Artist(name=new_name, information=new_information, url=new_url, user_id=user) session.add(new_artist) session.commit() new_artist_id = session.query(Artist).filter_by(name=new_name).one() message_create('artist', new_name) return redirect(url_for('showArtists', artist_id=new_artist_id.id)) else: return render_template('artist_add.html', login_session=login_session)
def makeAdd(categoryname): if not loggedIn(): return redirect('/login') user_id = getUserID(login_session['email']) if validators.url(request.form['image']): validIMG = request.form['image'] else: validIMG = '/static/male-avatar.png' theCategory = filter(lambda x: x.name == request.form['genre'], session.query(Category).all()) newArtist = Artist(name=request.form['name'], image=validIMG, shortname=createUniqShortname(request.form['name']), description=request.form['description'], category=theCategory[0], user_id=user_id) session.add(newArtist) session.commit() return redirect(url_for('showCategory', categoryname=categoryname))
def addArtist(): """ Adds a new artist to the Artist table in db """ user = login_session['user_id'] if request.method == 'POST': # Make sure an entry for artist does not already exist before # creating exisitingArtist = session.query(Artist).filter( Artist.name.ilike(request.form['artist_name'])).first() if not exisitingArtist: newArtist = Artist(name=request.form['artist_name'], creator_id=login_session['user_id']) session.add(newArtist) session.commit() return redirect(url_for('showArtists')) else: flash("This artist already exists") return redirect( url_for('showArtistDetails', idOfArtist=exisitingArtist.id, nameOfArtist=exisitingArtist.name, user=user)) else: return render_template('add_artist.html', user=user)
def search_artist(name): exists = False db.connect() artist = Artist().select().where(Artist.artist_name == name) if len(artist) > 0: exists = True db.close() return exists
def createArtist(form, login_session): newArtist = Artist(name=form['name'], image=form['image'], user_id=login_session['user_id']) session.add(newArtist) session.commit() flash("%s Added" % newArtist.name) return redirect(url_for('showArtists'))
def newArtist(): if request.method == 'POST': session = initSession() newItem = Artist(name=request.form['name'], gender=request.form['gender']) session.add(newItem) session.commit() return redirect(url_for('artist')) else: return render_template('newartist.html')
def newArtist(): if 'username' not in login_session: return redirect('/login') if request.method == 'POST': newArtist = Artist(name=request.form['name'], user_id=login_session['user_id']) session.add(newArtist) flash('New Artist %s Successfully Created' % newArtist.name) session.commit() return redirect(url_for('showArtists')) else: return render_template('newArtist.html')
def addNewArtist(): """ Add a New Artist """ if request.method == 'POST': newArtist = Artist(name=request.form['name'], picture=request.form['picture'], user_id=login_session['user_id']) session.add(newArtist) session.commit() flash('New Artist %s Successfully Created' % newArtist.name) return redirect(url_for('showAllArtists')) return render_template('newartist.html')
def newArtist(genre_id): if 'username' not in login_session: return redirect('/login') if request.method == 'POST': newItem = Artist(name=request.form['name'], description=request.form[ 'description'], genre_id=genre_id, user_id=login_session['username']) session.add(newItem) session.commit() return redirect(url_for('genreArtists', genre_id=genre_id)) else: return render_template('newmenuitem.html', genre_id=genre_id)
def newArtist(): genres = session.query(Genre).all() if request.method == 'POST': newArtist = Artist(name=request.form['artistName'], biography=request.form['artistBio'], created_at=datetime.datetime.today(), genre_id=request.form['artistGenre'], user_id=login_session['user_id']) session.add(newArtist) session.commit() flash('New Artist %s Successfully Created' % (newArtist.name)) return redirect(url_for('home')) else: return render_template('newArtist.html', genres=genres)
def newArtist(): # Only logged in users can create an artist if 'email' not in login_session: return redirect('/login') # Using the form located in forms.py form = ArtistForm(request.form) if request.method == 'POST' and form.validate(): newArtist = Artist(name=form.name.data, year_of_birth=form.year_of_birth.data, year_of_death=form.year_of_death.data, country=form.country.data, art_movement=form.art_movement.data, user_id=login_session['user_id']) db.session.add(newArtist) db.session.commit() return redirect(url_for('showArtists')) else: return render_template('newartist.html', form=form)
def newArtist(genre_id): login_session['state'] = state if 'username' not in login_session: return redirect(url_for('showArtist', genre_id=genre_id, state=state)) if request.method == 'POST': genre = session.query(Genre).filter_by(id=genre_id).one() newItem = Artist(name=request.form['name'], bio=request.form['bio'], genre_id=genre_id, user_id=login_session['user_id']) session.add(newItem) session.commit() flash('New Artist %s Successfully Created' % (newItem.name)) return redirect(url_for('showArtist', genre_id=genre_id, state=state)) else: return render_template('newArtist.html', genre_id=genre_id, state=state)
def newArtist(genre_id): if 'username' not in login_session: return redirect('/login') currentGenre = session.query(Genre).filter_by(id=genre_id).one() if login_session['user_id'] != currentGenre.user_id: return "<script>function myFunction() {alert('You are not authorized " "to add menu items to this restaurant. Please create your own " "restaurant in order to add items.');}</script><body " "onload='myFunction()''>" if request.method == 'POST': newAct = Artist(name=request.form['name'], bio=request.form['bio'], album=request.form['album'], albumImg=request.form['albumImg'], wikiLink=request.form['wikiLink'], release_year=request.form['release_year'], genre_id=genre_id, user_id=currentGenre.user_id) session.add(newAct) session.commit() flash('new artist created') return redirect(url_for('genrelist', genre_id=genre_id)) else: return render_template('new_artist.html', genre_id=genre_id)
def artist(session, name, spotify_id, images, user_id): ''' When passed an artist name and spotify_id, creates an artist record in the database ''' encoded_name = url_name(name) new_artist = Artist(name=name, spotify_id=spotify_id, url_name=url_name(name), created=datetime.datetime.utcnow(), user=int(user_id)) if images: for image in images: if image[u'width'] > ARTIST_IMAGE_WIDTH_LG: new_artist.img_url_lg = image[u'url'] elif image[u'width'] > ARTIST_IMAGE_WIDTH_MD: new_artist.img_url_md = image[u'url'] elif image[u'width'] > ARTIST_IMAGE_WIDTH_SM: new_artist.img_url_sm = image[u'url'] else: new_artist.img_url_xs = image[u'url'] session.add(new_artist)
'information' : "The Belgian sculptor (1918-1940) worked in the classic Art Deco period, the second important period of modern bronze cast scultpures.", 'url' : '', 'user_id' : 1}, ] for artist in artists: check_artist = session.query(Artist).filter_by(name = artist['name']).first() if check_artist: print "This artist %s seems to be already in the database." % artist['name'] print "Please check your input and use the front end" else: insert_artist= Artist(name = escape(artist['name']), information= escape(artist['information']), url = escape(artist['url']), user_id = artist['user_id'] ) session.add(insert_artist) print "The artist %s will be added to the database" % artist['name'] print "Committing..." session.commit() print print print "Artists committed" print print # 4. Artwork artworks = [{'name' : 'Albatros sur une vague',
Base.metadata.bind = engine DBSession = sessionmaker(bind=engine) session = DBSession() # Create dummy user user1 = User(name="Yana Kesala", email="*****@*****.**", id=1) session.add(user1) session.commit() user2 = User(name='Radiant Moxie', email='*****@*****.**', id=2) session.add(user2) session.commit() #Albums for Sting artist1 = Artist(user_id=1, name='Sting', picture='/static/Sting.jpg') session.add(artist1) session.commit() album1 = Album(name = 'Brand New Day', description = \ "From AllMusic.com:\ By the late '90s, Sting had reached a point where he didn't have to prove \ his worth every time out; \ he had so ingrained himself in pop culture, he really had the freedom to \ do whatever he wanted." , year_released = 1999, artist = artist1, picture = '/static/BrandNewDay.jpg', user_id = 1) session.add(album1) session.commit()
def create_artist(new_artist): db.connect() artist = Artist(artist_name=new_artist.name, email=new_artist.email) artist.save() db.close()
session.add(genre1) session.commit() genre1 = Genre(name="Easy Listening") session.add(genre1) session.commit() genre1 = Genre(name="Electronic Music") session.add(genre1) session.commit() artist1 = Artist(name="Daft Punk", description=""" Daft Punk is a French electronic music duo consisting of producers Guy-Manuel de Homem-Christo and Thomas Bangalter. """, genre=genre1) session.add(artist1) session.commit() artist2 = Artist(name="Deadmau5", description=""" Joel Thomas Zimmerman (a.k.a. deadmau5) is a Canadian DJ producer, formerly a web developer, who produces a wide variety of electronic musical genres, such as electro and dubstep, but is best known for pioneering work in the areas of progressive house and electrohouse. """, genre=genre1)
DBSession = sessionmaker(bind=engine) session = DBSession() # Create dummy user User1 = User(name="DB Created", email="*****@*****.**") session.add(User1) session.commit() genre1 = Genre(user_id=1, name="Alternative Rock") session.add(genre1) session.commit() artist1 = Artist( user_id=1, name="Panic at the Disco", bio= "Panic! at the Disco is an American rock band from Las Vegas, Nevada, formed in 2004 and featuring the current lineup of vocalist Brendon Urie, accompanied on tour by guitarist Kenneth Harris, drummer Dan Pawlovich, and bassist Nicole Row. Founded by Founded by childhood friends Ryan Ross, Spencer Smith, Brent Wilson and Urie, Panic! at the Disco recorded its first demos while its members were in high school.", genre=genre1) session.add(artist1) session.commit() artist2 = Artist( user_id=1, name="Fallout Boy", bio= "Fall Out Boy is an American rock band formed in Wilmette, Illinois, a suburb of Chicago, in 2001. The band consists of lead vocalist and rhythm guitarist Patrick Stump, bassist Pete Wentz, lead guitarist Joe Trohman, and drummer Andy Hurley. The band originated from Chicago's hardcore punk scene, with which all members were involved at one point. The group was formed by Wentz and Trohman as a pop punk side project of the members' respective hardcore bands, and Stump joined shortly thereafter.", genre=genre1) session.add(artist2) session.commit() artist3 = Artist(
User1 = User( name="Darold So", email="*****@*****.**", picture='https://avatars0.githubusercontent.com/u/9425789?v=3&s=460') session.add(User1) session.commit() genre1 = Genre(name="Rock", user=User1) session.add(genre1) session.commit() artist1 = Artist( name="Guns N' Roses", biography= """At a time when pop was dominated by dance music and pop-metal, Guns N' Roses brought raw, ugly rock & roll crashing back into the charts. They were not nice boys; nice boys don't play rock & roll. They were ugly, misogynistic, and violent; they were also funny, vulnerable, and occasionally sensitive, as their breakthrough hit, \"Sweet Child O' Mine,\" showed. While Slash and Izzy Stradlin ferociously spit out dueling guitar riffs worthy of Aerosmith or the Stones, Axl Rose screeched out his tales of sex, drugs, and apathy in the big city. Meanwhile, bassist Duff McKagan and drummer Steven Adler were a limber rhythm section who kept the music loose and powerful. Guns N' Roses' music was basic and gritty, with a solid hard, bluesy base; they were dark, sleazy, dirty, and honest -- everything that good hard rock and heavy metal should be. There was something refreshing about a band that could provoke everything from devotion to hatred, especially since both sides were equally right. There hadn't been a hard rock band this raw or talented in years, and they were given added weight by Rose's primal rage, the sound of confused, frustrated white trash vying for a piece of the pie. As the '80s became the '90s, there simply wasn't a more interesting band around, but owing to intra-band friction and the emergence of alternative rock, Rose's supporting cast eventually left, and he spent over 15 years recording before the long-delayed Chinese Democracy appeared in 2008.""", created_at=datetime.today(), genre=genre1, user=User1) session.add(artist1) session.commit() artist2 = Artist( name="Linkin Park", biography= """Although rooted in alternative metal, Linkin Park became one of the most successful acts of the 2000s by welcoming elements of hip-hop, modern rock, and atmospheric electronica into their music. The band's rise was indebted to the aggressive rap-rock movement made popular by the likes of Korn and Limp Bizkit, a movement that paired grunge's alienation with a bold, buzzing soundtrack. Linkin Park added a unique spin to that formula, however, focusing as much on the vocal interplay between singer Chester Bennington and rapper Mike Shinoda as the band's muscled instrumentation, which layered DJ effects atop heavy, processed guitars. While the group's sales never eclipsed those of its tremendously successful debut, Hybrid Theory, few alt-metal bands rivaled Linkin Park during the band's heyday.""", created_at=datetime.today(), genre=genre1, user=User1) session.add(artist2)
session = DBSession() # Category: Jazz genreJazz = Genre( name="Jazz", user_id="root", ) session.add(genreJazz) session.commit() artistJazz1 = Artist( name="Kamasi Washington", description= "Kamasi Washington (born February 18, 1981) is an American jazz saxophonist, composer, producer, and bandleader. Washington is known mainly for playing tenor saxophone.", instrument="Saxophone", labels="Young Turks, XL, Brainfeeder", associated_acts= "Flying Lotus, Ibeyi, Kendrick Lamar, Run the Jewels, Thundercat", user_id="root", genre=genreJazz) session.add(artistJazz1) session.commit() artistJazz2 = Artist( name="Brad Mehldau", description= "Bradford Alexander 'Brad' Mehldau is an American jazz pianist, composer, and arranger. Mehldau studied music at The New School, and toured and recorded while still a student.", instrument="Piano", labels="Warner Bros., Nonesuch", associated_acts= "Joshua Redman, Mark Guiliana, Chris Thile, Kurt Rosenwinkel",
picture="""https://lh3.googleusercontent.com/ -6jXvJsUFLfE/AAAAAAAAAAI/AAAAAAAAAAA/Xom8hrDa6bc/photo.jpg""") session.add(user1) session.commit() user2 = User(email='*****@*****.**', picture="""https://lh3.googleusercontent.com /-6jXvJsUFLfE/AAAAAAAAAAI/AAAAAAAAAAA/Xom8hrDa6bc/photo.jpg""") session.add(user2) session.commit() # Mondrian and associated artwork creation artist1 = Artist(name="Piet Mondrian", year_of_birth=1872, year_of_death=1944, country="Netherlands", art_movement="De Stijl", user=user1) session.add(artist1) session.commit() artwork1 = Artwork(title="Composition with Red Blue and Yellow", medium="oil", size="23.4in x 23.4in", year_created=1929, artist=artist1, user=user1) session.add(artwork1) session.commit()
# Add Category category3 = Category(user_id=1, name="Rap", shortname="rap") session.add(category3) session.commit() # Add Category category4 = Category(user_id=1, name="Rock", shortname="rock") session.add(category4) session.commit() # Add Artist artist1 = Artist( user_id=1, name="Taylor Swift", image= "https://tgm-liveweb-prod.s3.amazonaws.com/assets/article/2016/12/14/taylor_swift_big_announcements_feature.jpg", shortname="taylorswift", description="Juicy grilled veggie patty with tomato mayo and lettuce", category=category1) session.add(artist1) session.commit() artist2 = Artist( user_id=1, name="Calvin Harris", shortname="calvinharris", image= "http://www.billboard.com/files/media/calvin-harris-2017-press-billboard-1548.jpg", description="Juicy grilled veggie patty with tomato mayo and lettuce", category=category2) session.add(artist2)
DBSession = sessionmaker(bind=engine) session = DBSession() # User user1 = User(name='User', id=1, email='*****@*****.**') session.add(user1) session.commit() # Artists artist1 = Artist( name='The Afterparty', id=1, user_id=1, image= 'https://scontent-lhr3-1.xx.fbcdn.net/v/t1.0-9/10455424_10152853315166825_602796555442209128_n.jpg?oh=7cca7e89359c64fe8288d97822c36654&oe=591E0E14' ) session.add(artist1) session.commit() artist2 = Artist( name='Manchester Orchestra', id=2, user_id=1, image= 'http://www.billboard.com/files/styles/article_main_image/public/media/manchester-orchestra-andrewthomaslee-650-430.jpg' ) session.add(artist2) session.commit()
# declaratives can be accessed through a DBSession instance Base.metadata.bind = engine DBSession = sessionmaker(bind=engine) # Create the staging zone for all database changes session = DBSession() # Create dummy user User1 = User(name="Filburt Turtle", email="*****@*****.**", picture='https://i.ytimg.com/vi/gt5cl0jmrwA/hqdefault.jpg') session.add(User1) session.commit() # Add the Beatles beatles = Artist(user_id=1, name="The Beatles") session.add(beatles) session.commit() rubbersoul = Album( user_id=1, name="Rubber Soul", description= "Their first undeniable classic, the group shows an affinity for Bob Dylan with thoughtful lyricism", year='1965', numtracks="14", cover='http://www.beatlesinterviews.org/al6.jpg', artist=beatles) session.add(rubbersoul)
description="Something", region=region2, craft=craft7) session.add(handiCraft95) session.commit() handiCraft96 = HandiCraft( sub_craft="Wall decal", description= "A wall decal, also known as a wall sticker, wall tattoo, or wall vinyl, is a vinyl sticker that is affixed to a wall or other smooth surface for decoration and informational purposes. Wall decals are cut with vinyl cutting machines. Most decals use only one color, but some may have various images printed upon them.", region=region2, craft=craft7) session.add(handiCraft96) session.commit() artist1 = Artist(name="Anuja Verma") session.add(artist1) session.commit() photo1 = Photo( photoURL= "https://i.pinimg.com/736x/6c/4b/cb/6c4bcb707d06917954ff0a3f4fb5c177--mandala-wall-decal-mandala-decor.jpg", handicraft=handiCraft96) session.add(photo1) session.commit() video1 = Video(videoURL="https://www.youtube.com/watch?v=qvCRL2Z5_Ho", handicraft=handiCraft96) session.add(video1) session.commit()
def editArtwork(artwork_id): if not checkLogin(): return redirect(url_for('showArtworks', artwork_id=artwork_id)) if not checkUser(Artwork, artwork_id): return redirect(url_for('showArtworks', artwork_id=artwork_id)) artwork = session.query(Artwork).filter_by(id=artwork_id).one() if request.method == 'POST': # Enable the input of a new ART Discipline if request.form['new_art'] == 'False': artwork.art_id = request.form['art_id'] else: new_value = request.form['add_art'] # Create the new art entry new_Art = Art(type=new_value, user_id=1) session.add(new_Art) session.commit() message_create('art', new_value) # Get the new art id new_art = session.query(Art).filter_by(type=new_value).one() artwork.art_id = new_art.id # Enable the input of a new ARTIST if request.form['new_artist'] == 'False': artwork.artist_id = request.form['artist_id'] else: new_value = request.form['add_artist'] # Create the new art entry new_Artist = Artist(name=new_value, user_id=1) session.add(new_Artist) session.commit() message_create('artist', new_value) # Get the new art id new_artist = session.query(Artist).filter_by(name=new_value).one() artwork.art_id = new_artist.id artwork.name = request.form['name'] artwork.description = request.form['description'] artwork.purchase_year = request.form['purchase_year'] artwork.size = request.form['size'] artwork.weight = request.form['weight'] artwork.purchase_prize = request.form['purchase_prize'] # !!!!!!!!! Image Handling !!!!!!!!! # Delete the pictures targetedpictures = getList(request.form['delete_picture']) print targetedpictures if targetedpictures[0]: for targetedpicture in targetedpictures: target = session.query(Picture).filter_by( id=int(targetedpicture)).one() session.delete(target) # ///////// Image Handling ///////// session.commit() message_update('artwork', artwork.name) return redirect(url_for('showArtworks', artwork_id=artwork_id)) else: arts = session.query(Art).all() artists = session.query(Artist).all() return render_template('artwork_edit.html', artwork=artwork, arts=arts, artists=artists, login_session=login_session)
def addArtwork(): if not checkLogin(): return redirect(url_for('showArtCatalog')) if request.method == 'POST': # There is no risk of error as the existence of login_session['user_id'] # was checked by checkLogin() user = login_session['user_id'] # Enable the input of a new ART Discipline if request.form['new_art'] == 'False': new_art_id = request.form['art_id'] else: new_value = request.form['add_art'] # Create the new art entry new_Art = Art(type=new_value, user_id=user) session.add(new_Art) session.commit() message_create('art', new_value) # Get the new art id new_art = session.query(Art).filter_by(type=new_value).one() new_art_id = new_art.id # Enable the input of a new ARTIST if request.form['new_artist'] == 'False': new_artist_id = request.form['artist_id'] else: new_value = request.form['add_artist'] # Create the new art entry new_Artist = Artist(name=new_value, user_id=user) session.add(new_Artist) session.commit() message_create('artist', new_value) # Get the new art id new_artist = session.query(Artist).filter_by(name=new_value).one() new_artist_id = new_artist.id # Get the other input fields new_name = request.form['name'] new_description = request.form['description'] new_purchase_year = request.form['purchase_year'] new_size = request.form['size'] new_weight = request.form['weight'] new_purchase_prize = request.form['purchase_prize'] # Create the new entry new_artwork = Artwork(name=new_name, description=new_description, purchase_year=new_purchase_year, size=new_size, weight=new_weight, purchase_prize=new_purchase_prize, user_id=user, art_id=new_art_id, artist_id=new_artist_id) session.add(new_artwork) session.commit() # Get the new id new_artwork_id = session.query(Artwork).filter_by(name=new_name).one() message_create('artworks', new_name) return redirect(url_for('showArtworks', artwork_id=new_artwork_id.id)) else: arts = session.query(Art).all() artists = session.query(Artist).all() return render_template('artwork_add.html', arts=arts, artists=artists, login_session=login_session)