Пример #1
0
def display(request, gid):
    graph = get_object_or_404(Graphs, pk=gid)

    #OCTAL experiment: graph linearity based on user id
    p = None
    linear = 0
    participant = 0

    if graph.study_active:
        if request.user.is_authenticated():
            p = getParticipantByUID(request.user.pk, gid)

        #user has no participant ID yet, ask them for it
        if p is None:
            return HttpResponseRedirect(urlLanding(gid))

        # make sure participant completed the presurvey
        r = handleSurveys(p, gid)
        if r is not None: return HttpResponseRedirect(r)

        linear = int(p.linear)
        participant = int(p.isParticipant())

    return render(request, "map.html",{"full_graph_skeleton":graph, 
                              "graph_name": escape(strip_tags(graph.name)),
                              "linear":linear,
                              "participant":participant,
                              "editor":int(canEdit(request,gid)),
                              "study_active": int(graph.study_active),})
Пример #2
0
def display(request, gid):
    graph = get_object_or_404(Graphs, pk=gid)

    #OCTAL experiment: graph linearity based on user id
    p = None
    linear = 0
    participant = 0

    if graph.study_active:
        if request.user.is_authenticated():
            p = getParticipantByUID(request.user.pk, gid)

        #user has no participant ID yet, ask them for it
        if p is None:
            return HttpResponseRedirect(urlLanding(gid))

        # make sure participant completed the presurvey
        r = handleSurveys(p, gid)
        if r is not None: return HttpResponseRedirect(r)

        linear = int(p.linear)
        participant = int(p.isParticipant())

    return render(
        request, "map.html", {
            "full_graph_skeleton": graph,
            "graph_name": escape(strip_tags(graph.name)),
            "linear": linear,
            "participant": participant,
            "editor": int(canEdit(request, gid)),
            "study_active": int(graph.study_active),
        })
Пример #3
0
def event(request, event_id):
	sources = NewsSource.objects.all()
	feeds = NewsFeed.objects.all()
	articles = Article.objects.all()[:20]
	topEvents = NewsEvent.objects.all().order_by("score").reverse()[:5]
	event = NewsEvent.objects.get(id=event_id)
	event.viewCount += 1
	event.score += 1
	event.save()
	rating = utils.getRating(event_id, request.user)
	print rating
	canEdit = utils.canEdit(event_id, request.user)
	topEvents = NewsEvent.objects.all().order_by("score").reverse()[:5]
	tweets = Tweet.objects.all().reverse()[:5]
	recArticles, recSources = utils.getRecommendations(request.user)
	context = {'tweets':tweets, 'articles': articles, 'sources': sources, 'feeds': feeds, 'event': event, 'rating': rating, 'topEvents': topEvents, 'canEdit': canEdit, 'recArticles': recArticles, 'recSources': recSources}
	return render(request, 'event.html', context)