示例#1
0
def add_api_key(request):
    logger.debug("add_api_key called by user %s" % request.user)
    user_state = determine_membership_by_user(request.user)
    if request.method == 'POST':
        form = UpdateKeyForm(request.POST)
        form.user_state = user_state
        logger.debug("Request type POST with form valid: %s" % form.is_valid())
        if form.is_valid():
            EveManager.create_api_keypair(form.cleaned_data['api_id'],
                                          form.cleaned_data['api_key'],
                                          request.user)

            # Grab characters associated with the key pair
            characters = EveApiManager.get_characters_from_api(
                form.cleaned_data['api_id'], form.cleaned_data['api_key'])
            EveManager.create_characters_from_list(characters, request.user,
                                                   form.cleaned_data['api_id'])
            logger.info("Successfully processed api add form for user %s" %
                        request.user)
            return HttpResponseRedirect("/api_key_management/")
        else:
            logger.debug("Form invalid: returning to form.")
    else:
        logger.debug("Providing empty update key form for user %s" %
                     request.user)
        form = UpdateKeyForm()
        form.user_state = user_state
    context = {
        'form': form,
        'apikeypairs': EveManager.get_api_key_pairs(request.user.id)
    }
    return render_to_response('registered/addapikey.html',
                              context,
                              context_instance=RequestContext(request))
示例#2
0
def add_api_key(request):
    if request.method == 'POST':
        form = UpdateKeyForm(request.POST)

        if form.is_valid():
            EveManager.create_api_keypair(form.cleaned_data['api_id'],
                                          form.cleaned_data['api_key'],
                                          request.user)

            # Grab characters associated with the key pair
            characters = EveApiManager.get_characters_from_api(form.cleaned_data['api_id'],
                                                               form.cleaned_data['api_key'])
            EveManager.create_characters_from_list(characters, request.user, form.cleaned_data['api_id'])
            return HttpResponseRedirect("/api_key_management/")
    else:
        form = UpdateKeyForm()
    context = {'form': form, 'apikeypairs': EveManager.get_api_key_pairs(request.user.id)}
    return render_to_response('registered/addapikey.html', context,
                              context_instance=RequestContext(request))
示例#3
0
def add_api_key(request):
    logger.debug("add_api_key called by user %s" % request.user)
    user_state = determine_membership_by_user(request.user)
    if request.method == "POST":
        form = UpdateKeyForm(request.POST)
        form.user_state = user_state
        logger.debug("Request type POST with form valid: %s" % form.is_valid())
        if form.is_valid():
            EveManager.create_api_keypair(form.cleaned_data["api_id"], form.cleaned_data["api_key"], request.user)

            # Grab characters associated with the key pair
            characters = EveApiManager.get_characters_from_api(
                form.cleaned_data["api_id"], form.cleaned_data["api_key"]
            )
            EveManager.create_characters_from_list(characters, request.user, form.cleaned_data["api_id"])
            logger.info("Successfully processed api add form for user %s" % request.user)
            return HttpResponseRedirect("/api_key_management/")
        else:
            logger.debug("Form invalid: returning to form.")
    else:
        logger.debug("Providing empty update key form for user %s" % request.user)
        form = UpdateKeyForm()
        form.user_state = user_state
    context = {"form": form, "apikeypairs": EveManager.get_api_key_pairs(request.user.id)}
    return render_to_response("registered/addapikey.html", context, context_instance=RequestContext(request))
示例#4
0
def add_api_key(request):
    if request.method == 'POST':
        form = UpdateKeyForm(request.POST)

        if form.is_valid():
            EveManager.create_api_keypair(form.cleaned_data['api_id'],
                                          form.cleaned_data['api_key'],
                                          request.user)

            # Grab characters associated with the key pair
            characters = EveApiManager.get_characters_from_api(
                form.cleaned_data['api_id'], form.cleaned_data['api_key'])
            EveManager.create_characters_from_list(characters, request.user,
                                                   form.cleaned_data['api_id'])
            return HttpResponseRedirect("/api_key_management/")
    else:
        form = UpdateKeyForm()
    context = {
        'form': form,
        'apikeypairs': EveManager.get_api_key_pairs(request.user.id)
    }
    return render_to_response('registered/addapikey.html',
                              context,
                              context_instance=RequestContext(request))