def comentario(): id_resenha = request.form['id'] id_user = session['id'] review = request.form['comentario'] CommentsRepository().New(id_resenha, id_user, review) authorID = ResenhaRepository().FindById(id_resenha).author_id CommentsRepository().CommentNew(authorID) id = int(id_resenha) return redirect(url_for('res.resenhado', id=id))
def resenhado(id): if 'id' not in session: session['id'] = '' data = ResenhaRepository().FindById(id) spotifyId = data.spotify_id if data.tipo_review == 'artista': spotify = SpotifyGetOneArtist(spotifyId).oneArtist elif data.tipo_review == 'album': spotify = SpotifyGetOneAlbum(spotifyId).oneAlbum elif data.tipo_review == 'track': spotify = SpotifyGetOneTrack(spotifyId).oneTrack else: spotify = SpotifyGetOnePlaylist(spotifyId).onePlaylist user_author = UsersRepository().FindById(data.author_id) date = DateConversion(str(data.date_register)) like = CurtidasRepository().CountLikes(id).count commentsList = CommentsRepository().List(id) comment_user = UsersRepository().List() try: if CurtidasRepository().FindById(session['id'], id): PNG = 'unclick' else: PNG = 'click' except: PNG = 'click' if session['id'] != '': comments = CommentsRepository().listAuthorId(session['id']) likeNotifications = CurtidasRepository().listAuthorId(session['id']) usersNotifications = UsersRepository().List() resenhasListAll = ResenhaRepository().ListAll() notifyComment = UsersRepository().FindById(session['id']).read_comment notifyLike = UsersRepository().FindById(session['id']).read_like return render_template('resenha/resenhado.html', data=data, spotify=spotify, user_author=user_author, date=date, commentsList=commentsList, comment_user=comment_user, like=like, PNG=PNG, comments=comments, usersNotifications=usersNotifications, likeNotifications=likeNotifications, resenhasListAll=resenhasListAll, notifyComment=notifyComment, notifyLike=notifyLike) else: return render_template('resenha/resenhado.html', data=data, spotify=spotify, user_author=user_author, date=date, commentsList=commentsList, comment_user=comment_user, like=like, PNG=PNG)
def resenhaEdit(id): data = ResenhaRepository().FindById(id) spotifyId = data.spotify_id if data.tipo_review == 'artista': spotify = SpotifyGetOneArtist(spotifyId).oneArtist elif data.tipo_review == 'album': spotify = SpotifyGetOneAlbum(spotifyId).oneAlbum elif data.tipo_review == 'track': spotify = SpotifyGetOneTrack(spotifyId).oneTrack else: spotify = SpotifyGetOnePlaylist(spotifyId).onePlaylist if session['id'] != data.author_id: return redirect(url_for('ind.home')) else: voltarButton = request.headers.get("Referer") if session['id'] != '': comments = CommentsRepository().listAuthorId(session['id']) likeNotifications = CurtidasRepository().listAuthorId(session['id']) usersNotifications = UsersRepository().List() resenhasListAll = ResenhaRepository().ListAll() notifyComment = UsersRepository().FindById(session['id']).read_comment notifyLike = UsersRepository().FindById(session['id']).read_like return render_template('resenha/resenhaEdit.html', data=data, spotify=spotify, voltarButton=voltarButton, comments=comments, usersNotifications=usersNotifications, likeNotifications=likeNotifications, resenhasListAll=resenhasListAll, notifyComment=notifyComment, notifyLike=notifyLike) else: return render_template('resenha/resenhaEdit.html', data=data, spotify=spotify, voltarButton=voltarButton)
def editAccount(): if session['email'] == '' or 'email' not in session: flash('Você precisa logar para acessar essa área', 'info') return redirect(url_for('ind.home')) else: if session['id'] != '': comments = CommentsRepository().listAuthorId(session['id']) likeNotifications = CurtidasRepository().listAuthorId( session['id']) usersNotifications = UsersRepository().List() resenhasListAll = ResenhaRepository().ListAll() notifyComment = UsersRepository().FindById( session['id']).read_comment notifyLike = UsersRepository().FindById(session['id']).read_like return render_template('account/editAccount.html', user=UsersRepository().FindById( session['id']), comments=comments, usersNotifications=usersNotifications, likeNotifications=likeNotifications, resenhasListAll=resenhasListAll, notifyComment=notifyComment, notifyLike=notifyLike) else: return render_template('account/editAccount.html', user=UsersRepository().FindById( session['id']))
def index(): if 'id' not in session: __createSessionVariables() spotifyArtist = [] spotifyAlbum = [] spotifyTrack = [] spotifyPlaylist = [] users = UsersRepository().List() reviewsArtist = ResenhaRepository().List('artista', 6) reviewsAlbum = ResenhaRepository().List('album', 6) reviewsTrack = ResenhaRepository().List('track', 6) reviewsPlaylist = ResenhaRepository().List('playlist', 6) for item in reviewsArtist: spotifyArtist.append(SpotifyGetOneArtist(item.spotify_id).oneArtist) for item in reviewsAlbum: spotifyAlbum.append(SpotifyGetOneAlbum(item.spotify_id).oneAlbum) for item in reviewsTrack: spotifyTrack.append(SpotifyGetOneTrack(item.spotify_id).oneTrack) for item in reviewsPlaylist: spotifyPlaylist.append( SpotifyGetOnePlaylist(item.spotify_id).onePlaylist) if session['id'] != '': comments = CommentsRepository().listAuthorId(session['id']) likeNotifications = CurtidasRepository().listAuthorId(session['id']) usersNotifications = UsersRepository().List() resenhasListAll = ResenhaRepository().ListAll() notifyComment = UsersRepository().FindById(session['id']).read_comment notifyLike = UsersRepository().FindById(session['id']).read_like return render_template('index.html', reviewsArtist=reviewsArtist, reviewsAlbum=reviewsAlbum, reviewsTrack=reviewsTrack, reviewsPlaylist=reviewsPlaylist, users=users, spotifyArtist=spotifyArtist, spotifyAlbum=spotifyAlbum, spotifyTrack=spotifyTrack, spotifyPlaylist=spotifyPlaylist, mainFilter='index', comments=comments, usersNotifications=usersNotifications, likeNotifications=likeNotifications, resenhasListAll=resenhasListAll, notifyComment=notifyComment, notifyLike=notifyLike) else: return render_template('index.html', reviewsArtist=reviewsArtist, reviewsAlbum=reviewsAlbum, reviewsTrack=reviewsTrack, reviewsPlaylist=reviewsPlaylist, users=users, spotifyArtist=spotifyArtist, spotifyAlbum=spotifyAlbum, spotifyTrack=spotifyTrack, spotifyPlaylist=spotifyPlaylist, mainFilter='index')
def filterTrack(): if 'id' not in session: session['id'] = '' spotifyTrack = [] users = UsersRepository().List() reviewsTrack = ResenhaRepository().List('track') for item in reviewsTrack: spotifyTrack.append(SpotifyGetOneTrack(item.spotify_id).oneTrack) if session['id'] != '': comments = CommentsRepository().listAuthorId(session['id']) likeNotifications = CurtidasRepository().listAuthorId(session['id']) usersNotifications = UsersRepository().List() resenhasListAll = ResenhaRepository().ListAll() notifyComment = UsersRepository().FindById(session['id']).read_comment notifyLike = UsersRepository().FindById(session['id']).read_like return render_template('filters/filterTracks.html', reviewsTrack=reviewsTrack, spotifyTrack=spotifyTrack, users=users, comments=comments, notifyComment=notifyComment, notifyLike=notifyLike, usersNotifications=usersNotifications, likeNotifications=likeNotifications, resenhasListAll=resenhasListAll) else: return render_template('filters/filterTracks.html', reviewsTrack=reviewsTrack, spotifyTrack=spotifyTrack, users=users)
def resenhaListArtist(): artists = SpotifyGetFiveArtists(request.form['artist']).listArtists session['resenhaArtist'] = request.form['artist'] if session['id'] != '': comments = CommentsRepository().listAuthorId(session['id']) likeNotifications = CurtidasRepository().listAuthorId(session['id']) usersNotifications = UsersRepository().List() resenhasListAll = ResenhaRepository().ListAll() notifyComment = UsersRepository().FindById(session['id']).read_comment notifyLike = UsersRepository().FindById(session['id']).read_like return render_template('resenha/resenhaListArtist.html', artists=artists, comments=comments, usersNotifications=usersNotifications, likeNotifications=likeNotifications, resenhasListAll=resenhasListAll, notifyComment=notifyComment, notifyLike=notifyLike) else: return render_template('resenha/resenhaListArtist.html', artists=artists)
def resenhaListTracks(): tracks = SpotifyGetTracks(request.form['spotifyTracks']).createList() session['resenhaTrack'] = request.form['spotifyTracks'] if session['id'] != '': comments = CommentsRepository().listAuthorId(session['id']) likeNotifications = CurtidasRepository().listAuthorId(session['id']) usersNotifications = UsersRepository().List() resenhasListAll = ResenhaRepository().ListAll() notifyComment = UsersRepository().FindById(session['id']).read_comment notifyLike = UsersRepository().FindById(session['id']).read_like return render_template('resenha/resenhaListTracks.html', tracks=tracks, comments=comments, usersNotifications=usersNotifications, likeNotifications=likeNotifications, resenhasListAll=resenhasListAll, notifyComment=notifyComment, notifyLike=notifyLike) else: return render_template('resenha/resenhaListTracks.html', tracks=tracks)
def resenhalistAlbums(artistId): albums = SpotifyGetAlbums(artistId).createList() session['resenhaAlbums'] = artistId if session['id'] != '': comments = CommentsRepository().listAuthorId(session['id']) likeNotifications = CurtidasRepository().listAuthorId(session['id']) usersNotifications = UsersRepository().List() resenhasListAll = ResenhaRepository().ListAll() notifyComment = UsersRepository().FindById(session['id']).read_comment notifyLike = UsersRepository().FindById(session['id']).read_like return render_template('resenha/resenhaListAlbums.html', albums=albums, comments=comments, usersNotifications=usersNotifications, likeNotifications=likeNotifications, resenhasListAll=resenhasListAll, notifyComment=notifyComment, notifyLike=notifyLike) else: return render_template('resenha/resenhaListAlbums.html', albums=albums)
def _adm(): if session['id'] != '': comments = CommentsRepository().listAuthorId(session['id']) likeNotifications = CurtidasRepository().listAuthorId(session['id']) usersNotifications = UsersRepository().List() resenhasListAll = ResenhaRepository().ListAll() notifyComment = UsersRepository().FindById(session['id']).read_comment notifyLike = UsersRepository().FindById(session['id']).read_like return render_template('_adm.html', comments=comments, usersNotifications=usersNotifications, likeNotifications=likeNotifications, resenhasListAll=resenhasListAll, notifyComment=notifyComment, notifyLike=notifyLike) else: return render_template('_adm.html')
def resenhaListPlaylists(): if SpotifyCheckUser(request.form['spotifyUsername']): playlists = SpotifyGetPlaylists(request.form['spotifyUsername']).createList() if session['id'] != '': comments = CommentsRepository().listAuthorId(session['id']) likeNotifications = CurtidasRepository().listAuthorId(session['id']) usersNotifications = UsersRepository().List() resenhasListAll = ResenhaRepository().ListAll() notifyComment = UsersRepository().FindById(session['id']).read_comment notifyLike = UsersRepository().FindById(session['id']).read_like return render_template('resenha/resenhaListPlaylists.html', playlists=playlists, comments=comments, usersNotifications=usersNotifications, likeNotifications=likeNotifications, resenhasListAll=resenhasListAll, notifyComment=notifyComment, notifyLike=notifyLike) else: return render_template('resenha/resenhaListPlaylists.html', playlists=playlists) else: flash('Nome de usuário não encontrado', 'danger') return redirect(url_for('res.resenhaIndex'))
def resenhaIndex(): CleanSession() if session['email'] == '' or 'email' not in session: session['previous'] = 'res.resenhaIndex' flash('Você precisa logar para acessar essa área', 'info') return redirect(url_for('log.login')) if session['id'] != '': comments = CommentsRepository().listAuthorId(session['id']) likeNotifications = CurtidasRepository().listAuthorId(session['id']) usersNotifications = UsersRepository().List() resenhasListAll = ResenhaRepository().ListAll() notifyComment = UsersRepository().FindById(session['id']).read_comment notifyLike = UsersRepository().FindById(session['id']).read_like return render_template('resenha/resenhaIndex.html', comments=comments, usersNotifications=usersNotifications, likeNotifications=likeNotifications, resenhasListAll=resenhasListAll, notifyComment=notifyComment, notifyLike=notifyLike) else: return render_template('resenha/resenhaIndex.html')
def resenhaNewArtist(artistId): if session['email'] == '' or 'email' not in session: flash('Você precisa logar para acessar essa área', 'info') return redirect(url_for('log.login')) spotify = SpotifyGetOneArtist(artistId).createList() if session['id'] != '': comments = CommentsRepository().listAuthorId(session['id']) likeNotifications = CurtidasRepository().listAuthorId(session['id']) usersNotifications = UsersRepository().List() resenhasListAll = ResenhaRepository().ListAll() notifyComment = UsersRepository().FindById(session['id']).read_comment notifyLike = UsersRepository().FindById(session['id']).read_like return render_template('resenha/resenhaNew.html', spotify=spotify, tipo_review='artista', comments=comments, usersNotifications=usersNotifications, likeNotifications=likeNotifications, resenhasListAll=resenhasListAll, notifyComment=notifyComment, notifyLike=notifyLike) else: return render_template('resenha/resenhaNew.html', spotify=spotify, tipo_review='artista')
def ResenhasDelete(resenha_id): CommentsRepository().DeleteAllComments(resenha_id) ResenhaRepository().Delete(resenha_id) flash('Resenha Successfully removed', 'info') return redirect(url_for('adm.adm_resenhas'))
def commentRead(): CommentsRepository().CommentRead(session['id'])
def CommentDelete(comment_id, resenha_id): CommentsRepository().Delete(comment_id) flash('Comentário removido com sucesso', 'info') return redirect(url_for('res.resenhado', id=resenha_id))
def myPage(name, surname): if 'id' not in session: session['id'] = '' try: authorID = ResenhaRepository().FindAuthorByNameSurname( str(name).title(), str(surname).title()).id if not authorID: return redirect(url_for('ind.home')) reviews = ResenhaRepository().FindAuthorById(authorID) if not reviews: flash( f'{str(name).title()} {str(surname).title()} ainda não criou resenhas', 'info') return redirect(url_for('ind.home')) else: flash( f'Resenhas de {str(name).title()} {str(surname).title()}: ' f" resenhando.co/{str(name).lower()}-{str(surname).lower()} ", 'info') spotifyArtist = [] spotifyAlbum = [] spotifyTrack = [] spotifyPlaylist = [] reviewsArtist = [] reviewsAlbum = [] reviewsTrack = [] reviewsPlaylist = [] users = UsersRepository().List() for item in reviews: if item.tipo_review == 'artista': reviewsArtist.append(item) elif item.tipo_review == 'album': reviewsAlbum.append(item) elif item.tipo_review == 'track': reviewsTrack.append(item) elif item.tipo_review == 'playlist': reviewsPlaylist.append(item) for item in reviews: if item.tipo_review == 'artista': spotifyArtist.append( SpotifyGetOneArtist(item.spotify_id).oneArtist) elif item.tipo_review == 'album': spotifyAlbum.append( SpotifyGetOneAlbum(item.spotify_id).oneAlbum) elif item.tipo_review == 'track': spotifyTrack.append( SpotifyGetOneTrack(item.spotify_id).oneTrack) elif item.tipo_review == 'playlist': spotifyPlaylist.append( SpotifyGetOnePlaylist(item.spotify_id).onePlaylist) if session['id'] != '': comments = CommentsRepository().listAuthorId(session['id']) likeNotifications = CurtidasRepository().listAuthorId( session['id']) usersNotifications = UsersRepository().List() resenhasListAll = ResenhaRepository().ListAll() notifyComment = UsersRepository().FindById( session['id']).read_comment notifyLike = UsersRepository().FindById( session['id']).read_like return render_template('resenha/resenhaViews.html', reviewsArtist=reviewsArtist, reviewsAlbum=reviewsAlbum, reviewsTrack=reviewsTrack, reviewsPlaylist=reviewsPlaylist, users=users, spotifyArtist=spotifyArtist, spotifyAlbum=spotifyAlbum, spotifyTrack=spotifyTrack, spotifyPlaylist=spotifyPlaylist, mainFilter='myPage', comments=comments, usersNotifications=usersNotifications, likeNotifications=likeNotifications, resenhasListAll=resenhasListAll, notifyComment=notifyComment, notifyLike=notifyLike) else: return render_template('index.html', reviewsArtist=reviewsArtist, reviewsAlbum=reviewsAlbum, reviewsTrack=reviewsTrack, reviewsPlaylist=reviewsPlaylist, users=users, spotifyArtist=spotifyArtist, spotifyAlbum=spotifyAlbum, spotifyTrack=spotifyTrack, spotifyPlaylist=spotifyPlaylist, mainFilter='myPage') except: flash('Usuário não identificado', 'danger') return redirect(url_for('ind.home'))
def genresBody(genreLink): if 'id' not in session: session['id'] = '' genreLink = genreLink users = UsersRepository().List() genres = genres_model.genres resenhasListAll = ResenhaRepository().ListAll() spotifyArtist = [] spotifyAlbum = [] spotifyTrack = [] reviewsArtist = ResenhaRepository().ListOneGenre('artista', genreLink) for item in reviewsArtist: print(item.genre) reviewsAlbum = ResenhaRepository().ListOneGenre('album', genreLink) reviewsTrack = ResenhaRepository().ListOneGenre('track', genreLink) for item in reviewsArtist: spotifyArtist.append(SpotifyGetOneArtist(item.spotify_id).oneArtist) for item in reviewsAlbum: spotifyAlbum.append(SpotifyGetOneAlbum(item.spotify_id).oneAlbum) for item in reviewsTrack: spotifyTrack.append(SpotifyGetOneTrack(item.spotify_id).oneTrack) genreCount = {} for item in genres: count = 0 for genre in resenhasListAll: if genre.genre == item: count += 1 if count > 0: genreCount[item] = count if session['id'] != '': comments = CommentsRepository().listAuthorId(session['id']) likeNotifications = CurtidasRepository().listAuthorId(session['id']) usersNotifications = UsersRepository().List() notifyComment = UsersRepository().FindById(session['id']).read_comment notifyLike = UsersRepository().FindById(session['id']).read_like return render_template('filters/genresBody.html', users=users, reviewsArtist=reviewsArtist, reviewsAlbum=reviewsAlbum, reviewsTrack=reviewsTrack, spotifyArtist=spotifyArtist, spotifyAlbum=spotifyAlbum, spotifyTrack=spotifyTrack, comments=comments, usersNotifications=usersNotifications, likeNotifications=likeNotifications, notifyComment=notifyComment, notifyLike=notifyLike, genres=genres, genreCount=genreCount, genreLink=genreLink) else: return render_template('filters/genresBody.html', users=users, reviewsArtist=reviewsArtist, reviewsAlbum=reviewsAlbum, reviewsTrack=reviewsTrack, spotifyArtist=spotifyArtist, spotifyAlbum=spotifyAlbum, spotifyTrack=spotifyTrack, genres=genres, genreCount=genreCount, genreLink=genreLink)