def removeSelectedItems(request):
    """ Removes the selecteds ItemHarvesters from the user's harvesting list
    """
    user = request.user
    selection = getUserSelection(request)
    queryset = selection.getSavedQueryset(None, request.GET['tableId'])
    count = queryset.count()
    try:
        for item in queryset:
            user.userProfile.remove_item_from_harvest_list(item)
    except Exception:
        logError(
            'An error occured while removing selection from harvesting list')
        return jResponse({
            'error': {
                'code': 500,
                'message': 'Une erreur est survenue. Veuillez réessayer.'
            }
        })
    resetUserSelection(request)
    return jsonMessages([
        "{} élément{} {} été retiré{} de votre liste de "
        "collecte.".format(count, 's' if count > 1 else '',
                           'ont' if count > 1 else 'a',
                           's' if count > 1 else '')
    ])
def twTweetView(request, tweetId):
    tweet = None
    try:
        tweet = Tweet.objects.get(pk=tweetId)
    except:
        pass
    if not tweet:
        tweet = Tweet.objects.get(_ident=tweetId)
    if not tweet:
        raise Http404('No tweet matches that value')
    twUser = tweet.user
    context = {
        'user':
        request.user,
        'tweet':
        tweet,
        'navigator': [
            ("Twitter", "/twitter"),
            ((str(twUser) if twUser else 'Unidentifed TWUser'),
             ("/twitter/user/" + str(twUser.pk) if twUser else '#')),
            ("Tweet", ""),
        ],
    }
    resetUserSelection(request)
    return render(request, 'Twitter/TwitterTweet.html', context)
Beispiel #3
0
def playlistBase(request, identifier):
    resetUserSelection(request)
    try:
        playlist = YTPlaylist.objects.filter(pk=identifier).first()
    except:
        playlist = None
    if not playlist:
        playlist = YTPlaylist.objects.filter(_ident=identifier).first()
    if not playlist: raise Http404
    displayName = identifier
    if playlist.title:
        displayName = "Liste de lecture: %s" % playlist.title
    channel = playlist.channel

    context = {
        'user':
        request.user,
        "navigator": [
            ("Youtube", "/youtube"),
            (channel, channel.getLink()),
            (displayName, "/youtube/playlist/%s" % identifier),
        ],
        "playlist":
        playlist
    }
    request, context = addMessagesToContext(request, context)
    return render(request, 'Youtube/YoutubePlaylist.html', context)
Beispiel #4
0
def youtubeBase(request):
    context = {
        'user': request.user,
        "navigator": [
            ("Youtube", "/youtube"),
        ]
    }
    resetUserSelection(request)
    return render(request, 'Youtube/YoutubeBase.html', context)
Beispiel #5
0
def facebookBase(request):
    context = {
        'user': request.user,
        "navigator": [
            ("Facebook", "/facebook"),
        ],
    }
    resetUserSelection(request)
    return render(request, 'Facebook/FacebookBase.html', context)
def twitterBaseView(request):
    context = {
        'user': request.user,
        "navigator": [
            ("Twitter", "/twitter"),
        ]
    }
    log(context)
    resetUserSelection(request)
    return render(request, 'Twitter/TwitterBase.html', context)
Beispiel #7
0
def collections_dashboard(request):
    context = {
        'user': request.user,
        "navigator": [
            ("Collectes", "/collection"),
        ],
    }
    resetUserSelection(request)
    return render(request, 'Collection/containers/Collection_Dashboard.html',
                  context)
def lineChart(request):
    if 'ajax' in request.GET and request.GET['ajax'] == 'true':
        return ajax_lineChart(request)
    context = {
        'user':
        request.user,
        'navigator': [("Analytique", "#"), ("Temporel", "#"),
                      (re.sub('_', ' ', request.GET['chart_type']), '#')],
        'chart_type':
        request.GET['chart_type'],
    }
    resetUserSelection(request)
    return render(request, 'tool/lineChartTool.html', context)
Beispiel #9
0
def collection_detail(request, collection_id):
    collection = get_object_or_404(Collection, id=collection_id)
    context = {
        "navigator": [
            ("Collectes", "/collection"),
            (collection, "/collection/%s" % collection.pk),
        ],
        "collection":
        collection,
    }
    resetUserSelection(request)
    return render(request, "Collection/containers/Collection_Details.html",
                  context)
def lineChart(request):
    if 'ajax' in request.GET and request.GET['ajax']=='true': return ajax_lineChart(request)
    context = {
        'user': request.user,
        'navigator': [
            ("Analysis tools", "#"),
            ("Timeline", "#"),
            (request.GET['chart_type'], '#')
        ],
        'chart_type': request.GET['chart_type'],
    }
    resetUserSelection(request)
    return render(request,'tool/lineChartTool.html', context)
def pieChart(request):
    if 'ajax' in request.GET and request.GET['ajax'] == 'true':
        return ajax_pieChart(request)
    chart_type = request.GET[
        'chart_type'] if 'chart_type' in request.GET else 'location'
    context = {
        'user': request.user,
        'chart_type': chart_type,
        'navigator': [("Analytique", "#"), ("Proportion", "#"),
                      (chart_type, '#')],
    }
    resetUserSelection(request)
    return render(request, 'tool/pieChartTool.html', context)
def pieChart(request):
    if 'ajax' in request.GET and request.GET['ajax'] == 'true': return ajax_pieChart(request)
    chart_type = request.GET['chart_type'] if 'chart_type' in request.GET else 'location'
    context = {
        'user': request.user,
        'chart_type': chart_type,
        'navigator': [
             ("Analysis tools","#"),
             ("Proportion", "#"),(chart_type,'#')
        ],
    }
    resetUserSelection(request)
    return render(request,'tool/pieChartTool.html', context)
Beispiel #13
0
def userDashboard(request):
    resetUserSelection(request)
    aspiraUser = request.user.userProfile
    context = {
        'user': request.user,
        "navigator": [
            ("Tableau de bord", "/"),
        ],
        "twStats": getTwitterStats(aspiraUser),
        "ytStats": getYoutubeStats(aspiraUser),
        "fbStats": getFacebookStats(aspiraUser),
    }
    return render(request, 'AspiraUser/dashboard.html', context)
Beispiel #14
0
def search(request):
    resetUserSelection(request)
    terms = []
    query = ""
    if "query" in request.GET:
        query = request.GET['query']
    terms = digestQuery(query)
    return render(
        request, "AspiraUser/search_results.html", {
            'user': request.user,
            "navigator": [
                ("Recherche: \"%s\"" % "\"+\"".join(terms), "#"),
            ],
            "query": cleanQuery(query),
        })
Beispiel #15
0
def channelBase(request, identifier):
    resetUserSelection(request)
    try:
        channel = YTChannel.objects.filter(pk=identifier).first()
    except:
        channel = None
    if not channel:
        channel = YTChannel.objects.filter(_ident=identifier).first()
    if not channel: raise Http404
    context = {
        'user': request.user,
        "navigator": [
            ("Youtube", "/youtube"),
            ("Chaine: %s" % channel, channel.getLink()),
        ],
        "channel": channel
    }
    return render(request, 'Youtube/YoutubeChannel.html', context)
def twHashtagView(request, TWHashtagTerm):
    hashtag = None
    try:
        hashtag = Hashtag.objects.get(pk=TWHashtagTerm)
    except:
        try:
            hashtag = Hashtag.objects.get(term=TWHashtagTerm)
        except:
            raise Http404('No hashtag matches that value')
    context = {
        'user': request.user,
        'hashtag': hashtag,
        'navigator': [
            ("Twitter", "/twitter"),
            ("#%s" % hashtag.term, ""),
        ],
    }
    resetUserSelection(request)
    return render(request, 'Twitter/TwitterHashtag.html', context)
Beispiel #17
0
def fbUserView(request, FBUserId):
    fbUser = FBUser.objects.filter(pk=FBUserId)
    if not fbUser:
        fbUser = FBUser.objects.filter(_ident=FBUserId)
    if not fbUser:
        raise Http404
    else:
        fbUser = fbUser[0]
    context = {
        'user':
        request.user,
        'fbUser':
        fbUser,
        "navigator": [
            ("Facebook", "/facebook"),
            (fbUser, "/facebook/user/%s" % FBUserId),
        ],
    }
    resetUserSelection(request)
    return render(request, 'Facebook/FacebookUser.html', context)
Beispiel #18
0
def fbCommentView(request, fbCommentId):
    log(fbCommentId)
    fbComment = FBComment.objects.filter(pk=fbCommentId).first()
    if not fbComment:
        fbComment = FBComment.objects.filter(_ident=fbCommentId).first()
    log(fbComment)
    if not fbComment:
        raise Http404()
    context = {
        'fbComment':
        fbComment,
        'user':
        request.user,
        "navigator":
        [("Facebook", "/facebook"),
         (fbComment.from_profile, fbComment.from_profile.getLink()),
         ("Commentaire facebook", "/facebook/post/%s" % fbComment.pk)],
    }
    resetUserSelection(request)
    return render_to_response('Facebook/FacebookComment.html', context)
Beispiel #19
0
def fbPostView(request, FBPostId):
    fbPost = FBPost.objects.filter(pk=FBPostId)
    if not fbPost:
        fbPost = FBPost.objects.filter(_ident=FBPostId)
    if not fbPost:
        raise Http404
    else:
        fbPost = fbPost[0]
    context = {
        'fbPost':
        fbPost,
        'user':
        request.user,
        "navigator": [("Facebook", "/facebook"),
                      (fbPost.from_profile, fbPost.from_profile.getLink()),
                      ("%s Facebook" % fbPost.getTypeFrench(),
                       "/facebook/post/%s" % fbPost.pk)],
    }
    resetUserSelection(request)
    return render_to_response('Facebook/FacebookPost.html', context)
def twUserView(request, TWUser_value):
    twUser = get_object_or_404(TWUser, pk=TWUser_value)
    context = {
        'user':
        request.user,
        'twUser':
        twUser,
        'navigator': [
            ("Twitter", "/twitter"),
            (str(twUser), "/twitter/user/{}".format(twUser.pk)),
        ],
    }
    if 'snippet' in request.GET and request.GET['snippet'] == 'true':
        try:
            return render_to_response('Twitter/TwitterUserSnip.html', context)
        except:
            pass
    else:
        resetUserSelection(request)
        return render(request, 'Twitter/TwitterUser.html', context)
Beispiel #21
0
def fbPageView(request, FBPageId):
    fbPage = FBPage.objects.filter(pk=FBPageId)
    if not fbPage:
        fbPage = FBPage.objects.filter(_ident=FBPageId)
    if not fbPage:
        raise Http404
    else:
        fbPage = fbPage[0]
    context = {
        'user':
        request.user,
        'page':
        fbPage,
        'FBPageId':
        FBPageId,
        "navigator": [
            ("Facebook", "/facebook"),
            (fbPage, "/facebook/page/%s" % FBPageId),
        ],
    }
    resetUserSelection(request)
    return render(request, 'Facebook/FacebookPage.html', context)