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)
Esempio n. 2
0
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')
Esempio n. 3
0
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)
Esempio n. 4
0
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)
Esempio n. 5
0
def resenhaNewTrack(trackId):
    if session['email'] == '' or 'email' not in session:
        flash('Você precisa logar para acessar essa área', 'info')
        return redirect(url_for('log.login'))

    spotify = SpotifyGetOneTrack(trackId).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='track', comments=comments,
                               usersNotifications=usersNotifications, likeNotifications=likeNotifications,
                               resenhasListAll=resenhasListAll, notifyComment=notifyComment, notifyLike=notifyLike)
    else:
        return render_template('resenha/resenhaNew.html', spotify=spotify, tipo_review='track')
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)