def steam(request, *args, **kwargs):
	try:
		steam = Steam.objects.get(userId = request.user.social_auth.uid)
	except Steam.DoesNotExist:   
		steam = Steam(steamId= request.GET.get("openid.claimed_id","not found"), userId = request.user.social_auth.uid)
    
	steamId = steam.steamId.partition("http://steamcommunity.com/openid/id/")
	r = requests.get('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key='+settings.STEAM_HASH+'&steamids='+steamId[2])
	steam.name = r.json["response"]["players"][0]["personaname"] 
	steam.avatar = r.json["response"]["players"][0]["avatarfull"] 


	return request
Ejemplo n.º 2
0
def info(request):
    if request.user.is_anonymous():
        return render_to_response('tf2rpg/index.html', {}, context_instance=RequestContext(request))

    try:
       steam = Steam.objects.get(steamId = request.user.social_auth.get(user_id = request.user.id).uid)
    except Steam.DoesNotExist: 
       steam = Steam(steamId = request.user.social_auth.get(user_id = request.user.id).uid, userId = request.user.id, name = "Hola", avatar = "Hola") 
    
    steamId = steam.steamId.partition("http://steamcommunity.com/openid/id/")
    r = requests.get('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key='+settings.STEAM_HASH+'&steamids='+steamId[2])
    steam.name = r.json["response"]["players"][0]["personaname"] 
    steam.avatar = r.json["response"]["players"][0]["avatarfull"] 
    steam.save()

    t = loader.get_template('tf2rpg/characters/game.html')
    c = RequestContext(request,{
        'name': steam.name,
        'avatar': steam.avatar,
    })

    return HttpResponse(t.render(c))