Пример #1
0
def generate_request_token(request):
    #print request.path
    login_check_result = check_user_login(request)
    if (login_check_result != None):
        return login_check_result
    resource_id = myutil.get_http_param(request, "resource_id")
    consumer_id = myutil.get_http_param(request, "consumer_id")
    if (resource_id == None or consumer_id == None):
        context_tokenmanagers = get_list_tokenManagers()
        context_resources = get_list_resources()
        context_consumers = get_list_consumers()
        context = {
            "tokenmanagers": context_tokenmanagers,
            "resources":context_resources, 
            "consumers":context_consumers, 
            "user":myutil.check_user(request)}
        context_instance = RequestContext(request)
        template_name = "generate_request_token.html"
        return render_to_response(template_name, context, context_instance)
    else:
        print "ff"
        resource_id = eval(resource_id)[0]
        consumer_id = eval(consumer_id)[0]
        user = request.user
        resource = Resource.objects.get(id=resource_id)
        consumer = Consumer.objects.get(id=consumer_id)
        print user
        print resource
        print consumer
        token = tokenmanager_get_or_create(user, resource, consumer)
        return HttpResponseRedirect("/sauth/generate_request_token/")
Пример #2
0
def resource_add(request):
    print request.POST
    param_resource_name = myutil.get_http_param(request, "resource_name")
    param_resource_url = myutil.get_http_param(request, "resource_url")
    param_resource_readonly = myutil.get_http_param(request, "resource_readonly")
    if (param_resource_name != None and param_resource_url != None and param_resource_readonly != None):
        resource_name = param_resource_name
        resource_url = param_resource_url
        resource_readonly = (param_resource_readonly.strip() == "true")
        resource = resource_get_or_create(resource_name, resource_url, resource_readonly)
        print resource
    print resource_readonly
    return HttpResponseRedirect("/sauth/generate_request_token/")
Пример #3
0
def consumer_add(request):
    print request.POST
    login_check_result = check_user_login(request)
    if (login_check_result != None):
        return login_check_result
    param_consumer_name = myutil.get_http_param(request, "consumer_name")
    param_consumer_desc = myutil.get_http_param(request, "consumer_description")
    param_consumer_target = myutil.get_http_param(request, "consumer_request_target")
    if (param_consumer_name != None and param_consumer_desc != None and param_consumer_target != None):
        consumer_name = param_consumer_name
        consumer_desc = param_consumer_desc
        consumer_target = param_consumer_target
        user = request.user
        consumer = consumer_get_or_create(user, consumer_name, consumer_desc, consumer_target)
        print consumer
    return HttpResponseRedirect("/sauth/generate_request_token/")