예제 #1
0
def adduser(request):
	data = None
	name = None
	if(request.POST.get('name')):
		data = request.POST
		name = data.get('name')
	else:		
		data = request.raw_post_data
		data = json.loads(data)
		name = data['name']	
		

	user = User(name=name, photo=request.FILES['photo'])
	user.save()
	
	return HttpResponse(user.id)
예제 #2
0
def adduser(request):
    data = None
    fbid = None
    if(request.POST.get('fbid')):
        data = request.POST
        fbid = data.get('fbid')
    else:
        data = request.raw_post_data
        data = json.loads(data)
        fbid = data['fbid']

    response = "WTF -- added more than once?"
    user = User.objects.filter(fb_id=fbid)
    if(user.count() == 1):
        user[0].active = True
        user[0].save()
        response = user[0].id
    elif(user.count() == 0):
        user = User(fb_id=fbid)
        user.save()
        response = user.id

    return HttpResponse(fbid)