Example #1
0
def homepage(request):

    template = {"LOGIN_URL": settings.LOGIN_URL}

    if request.user.is_authenticated():
        user_profile = None
        try:
            user_profile = request.user.get_profile()
        except:
            # On first login, a user will not have a profile...what to do?
            new_profile = Profile()
            new_profile.user = request.user

            new_client = Client(name=request.user.username + "_pds",
                                user=request.user,
                                description="user " + request.user.username +
                                "'s Personal Data Store",
                                redirect_uri="http://" +
                                new_profile.pds_location + "/?username="******"access_token"] = access_tokens[0].token if len(
            access_tokens) > 0 else None
        template["clients"] = clients
        template["profile"] = user_profile
        template['form'] = form
        template['isup'] = is_pds_up(user_profile)

    return render_to_response('base/homepage.html', template,
                              RequestContext(request))
def homepage(request):
#    import pydevd;pydevd.settrace('127.0.0.1',port=5678)
    template = {}

    if request.user.is_authenticated():
	user_profile = None
	try:
	    user_profile = request.user.get_profile()
	except:
	    # On first login, a user will not have a profile...what to do?
	    new_profile = Profile()
	    new_profile.user = request.user
	
	    new_client = Client(name=request.user.username+"_pds", user=request.user, description="user "+request.user.username+"'s Personal Data Store", redirect_uri="http://"+new_profile.pds_ip+":"+new_profile.pds_port+"/?username="******":")

	    new_profile.pds_ip = new_location[0]
	    new_profile.pds_port = new_location[1]
	    new_profile.save()

        clients = Client.objects.filter(user=request.user)
        access_tokens = AccessToken.objects.filter(user=request.user).select_related()
#        funf_access_token = AccessToken.objects.get_or_create(user=request.user, scope="funf_write")
#        access_tokens = access_tokens.select_related()
	form = LocationForm()

        template["access_tokens"] = access_tokens
        template["clients"] = clients
        template["profile"] = user_profile
	template['form']=form
	template['isup']=is_pds_up(user_profile)

    return render_to_response(
        'base/homepage.html', 
        template, 
        RequestContext(request))
Example #3
0
def homepage(request):

    template = {"LOGIN_URL": settings.LOGIN_URL}

    if request.user.is_authenticated():
        user_profile = None
        try:
            user_profile = request.user.get_profile()
        except:
            # On first login, a user will not have a profile...what to do?
            new_profile = Profile()
            new_profile.user = request.user

            new_client = Client(
                name=request.user.username + "_pds",
                user=request.user,
                description="user " + request.user.username + "'s Personal Data Store",
                redirect_uri="http://" + new_profile.pds_location + "/?username="******"location"):
            new_profile = request.user.get_profile()
            new_location = request.GET["location"]
            new_profile.pds_location = new_location
            new_profile.save()

        clients = Client.objects.filter(user=request.user)
        access_tokens = AccessToken.objects.filter(user=request.user).select_related()
        #        access_tokens = access_tokens.select_related()
        form = LocationForm()
        # print access_tokens[0].token
        template["access_token"] = access_tokens[0].token if len(access_tokens) > 0 else None
        template["clients"] = clients
        template["profile"] = user_profile
        template["form"] = form
        template["isup"] = is_pds_up(user_profile)

    return render_to_response("base/homepage.html", template, RequestContext(request))