Пример #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 main_character_change(request, char_id):
    if EveManager.check_if_character_owned_by_user(char_id, request.user):
        previousmainid = AuthServicesInfoManager.get_auth_service_info(request.user).main_char_id
        AuthServicesInfoManager.update_main_char_Id(char_id, request.user)
        # Check if character is in the alliance
        character_info = EveManager.get_character_by_id(char_id)
        corporation_info = EveManager.get_corporation_info_by_id(character_info.corporation_id)

        if EveManager.get_charater_alliance_id_by_id(char_id) == settings.ALLIANCE_ID:
            add_member_permission(request.user, 'alliance_member')
            add_user_to_group(request.user, settings.DEFAULT_ALLIANCE_GROUP)
            add_user_to_group(request.user,
                              generate_corp_group_name(EveManager.get_character_by_id(char_id).corporation_name))

        elif corporation_info != None:
            if corporation_info.is_blue:
                add_member_permission(request.user, 'blue_member')
                add_user_to_group(request.user, settings.DEFAULT_BLUE_GROUP)
                AuthServicesInfoManager.update_is_blue(True, request.user)
            else:
                if check_if_user_has_permission(request.user, 'alliance_member'):
                    disable_alliance_member(request.user, previousmainid)

                if check_if_user_has_permission(request.user, 'blue_member'):
                    disable_blue_member(request.user)
        else:
            # TODO: disable serivces
            if check_if_user_has_permission(request.user, 'alliance_member'):
                disable_alliance_member(request.user, previousmainid)

            if check_if_user_has_permission(request.user, 'blue_member'):
                disable_blue_member(request.user)

        return HttpResponseRedirect("/characters")
    return HttpResponseRedirect("/characters")
Пример #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 api_key_removal(request, api_id):
    logger.debug("api_key_removal called by user %s for api id %s" %
                 (request.user, api_id))
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    # Check if our users main id is in the to be deleted characters
    characters = EveManager.get_characters_by_owner_id(request.user.id)
    if characters is not None:
        for character in characters:
            if character.character_id == authinfo.main_char_id:
                if character.api_id == api_id:
                    # TODO: Remove services also
                    if authinfo.is_blue:
                        logger.debug(
                            "Blue user %s deleting api for main character. Disabling."
                            % request.user)
                        disable_blue_member(request.user)
                    else:
                        logger.debug(
                            "User %s deleting api for main character. Disabling."
                            % request.user)
                        disable_member(request.user, authinfo.main_char_id)

    EveManager.delete_api_key_pair(api_id, request.user.id)
    EveManager.delete_characters_by_api_id(api_id, request.user.id)
    logger.info(
        "Succesfully processed api delete request by user %s for api %s" %
        (request.user, api_id))
    return HttpResponseRedirect("/api_key_management/")
Пример #5
0
def disable_alliance_member(user, char_id):
    remove_member_permission(user, 'alliance_member')
    remove_user_from_group(user, settings.DEFAULT_ALLIANCE_GROUP)
    remove_user_from_group(user,
                           generate_corp_group_name(
                               EveManager.get_character_by_id(char_id).corporation_name))
    deactivate_services(user)
Пример #6
0
def main_character_change(request, char_id):
    logger.debug("main_character_change called by user %s for character id %s" % (request.user, char_id))
    if EveManager.check_if_character_owned_by_user(char_id, request.user):
        AuthServicesInfoManager.update_main_char_Id(char_id, request.user)
        set_state(request.user)
        return HttpResponseRedirect("/characters")
    return HttpResponseRedirect("/characters")
Пример #7
0
def disable_member(user, char_id):
    logger.debug("Disabling user %s with character id %s" % (user, char_id))
    remove_member_permission(user, "member")
    remove_user_from_group(user, settings.DEFAULT_AUTH_GROUP)
    remove_user_from_group(user, generate_corp_group_name(EveManager.get_character_by_id(char_id).corporation_name))
    deactivate_services(user)
    logger.info("Disabled member %s" % user)
Пример #8
0
def api_key_management_view(request):
    logger.debug("api_key_management_view called by user %s" % request.user)
    context = {'apikeypairs': EveManager.get_api_key_pairs(request.user.id)}

    return render_to_response('registered/apikeymanagment.html',
                              context,
                              context_instance=RequestContext(request))
Пример #9
0
def characters_view(request):
    logger.debug("characters_view called by user %s" % request.user)
    render_items = {
        "characters": EveManager.get_characters_by_owner_id(request.user.id),
        "authinfo": AuthServicesInfoManager.get_auth_service_info(request.user),
    }
    return render_to_response("registered/characters.html", render_items, context_instance=RequestContext(request))
Пример #10
0
def characters_view(request):
    render_items = {
        'characters': EveManager.get_characters_by_owner_id(request.user.id),
        'authinfo': AuthServicesInfoManager.get_auth_service_info(request.user)
    }
    return render_to_response('registered/characters.html',
                              render_items,
                              context_instance=RequestContext(request))
Пример #11
0
def disable_alliance_member(user, char_id):
    remove_member_permission(user, 'alliance_member')
    remove_user_from_group(user, settings.DEFAULT_ALLIANCE_GROUP)
    remove_user_from_group(
        user,
        generate_corp_group_name(
            EveManager.get_character_by_id(char_id).corporation_name))
    deactivate_services(user)
Пример #12
0
def api_key_removal(request, api_id):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    # Check if our users main id is in the to be deleted characters
    characters = EveManager.get_characters_by_owner_id(request.user.id)
    if characters is not None:
        for character in characters:
            if character.character_id == authinfo.main_char_id:
                if character.api_id == api_id:
                    # TODO: Remove servies also
                    if authinfo.is_blue:
                        disable_blue_member(request.user)
                    else:
                        disable_alliance_member(request.user, authinfo.main_char_id)

    EveManager.delete_api_key_pair(api_id, request.user.id)
    EveManager.delete_characters_by_api_id(api_id, request.user.id)

    return HttpResponseRedirect("/api_key_management/")
Пример #13
0
def main_character_change(request, char_id):
    logger.debug(
        "main_character_change called by user %s for character id %s" %
        (request.user, char_id))
    if EveManager.check_if_character_owned_by_user(char_id, request.user):
        AuthServicesInfoManager.update_main_char_Id(char_id, request.user)
        set_state(request.user)
        return HttpResponseRedirect("/characters/")
    return HttpResponseRedirect("/characters/")
Пример #14
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))
Пример #15
0
def disable_member(user, char_id):
    logger.debug("Disabling user %s with character id %s" % (user, char_id))
    remove_member_permission(user, 'member')
    remove_user_from_group(user, settings.DEFAULT_AUTH_GROUP)
    remove_user_from_group(
        user,
        generate_corp_group_name(
            EveManager.get_character_by_id(char_id).corporation_name))
    deactivate_services(user)
    logger.info("Disabled member %s" % user)
Пример #16
0
def api_key_removal(request, api_id):
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    # Check if our users main id is in the to be deleted characters
    characters = EveManager.get_characters_by_owner_id(request.user.id)
    if characters is not None:
        for character in characters:
            if character.character_id == authinfo.main_char_id:
                if character.api_id == api_id:
                    # TODO: Remove servies also
                    if authinfo.is_blue:
                        disable_blue_member(request.user)
                    else:
                        disable_alliance_member(request.user,
                                                authinfo.main_char_id)

    EveManager.delete_api_key_pair(api_id, request.user.id)
    EveManager.delete_characters_by_api_id(api_id, request.user.id)

    return HttpResponseRedirect("/api_key_management/")
Пример #17
0
def main_character_change(request, char_id):
    if EveManager.check_if_character_owned_by_user(char_id, request.user):
        previousmainid = AuthServicesInfoManager.get_auth_service_info(
            request.user).main_char_id
        AuthServicesInfoManager.update_main_char_Id(char_id, request.user)
        # Check if character is in the alliance
        character_info = EveManager.get_character_by_id(char_id)
        corporation_info = EveManager.get_corporation_info_by_id(
            character_info.corporation_id)

        if EveManager.get_charater_alliance_id_by_id(
                char_id) == settings.ALLIANCE_ID:
            add_member_permission(request.user, 'alliance_member')
            add_user_to_group(request.user, settings.DEFAULT_ALLIANCE_GROUP)
            add_user_to_group(
                request.user,
                generate_corp_group_name(
                    EveManager.get_character_by_id(char_id).corporation_name))

        elif corporation_info != None:
            if corporation_info.is_blue:
                add_member_permission(request.user, 'blue_member')
                add_user_to_group(request.user, settings.DEFAULT_BLUE_GROUP)
                AuthServicesInfoManager.update_is_blue(True, request.user)
            else:
                if check_if_user_has_permission(request.user,
                                                'alliance_member'):
                    disable_alliance_member(request.user, previousmainid)

                if check_if_user_has_permission(request.user, 'blue_member'):
                    disable_blue_member(request.user)
        else:
            # TODO: disable serivces
            if check_if_user_has_permission(request.user, 'alliance_member'):
                disable_alliance_member(request.user, previousmainid)

            if check_if_user_has_permission(request.user, 'blue_member'):
                disable_blue_member(request.user)

        return HttpResponseRedirect("/characters")
    return HttpResponseRedirect("/characters")
Пример #18
0
def api_key_removal(request, api_id):
    logger.debug("api_key_removal called by user %s for api id %s" % (request.user, api_id))
    authinfo = AuthServicesInfoManager.get_auth_service_info(request.user)
    # Check if our users main id is in the to be deleted characters
    characters = EveManager.get_characters_by_owner_id(request.user.id)
    if characters is not None:
        for character in characters:
            if character.character_id == authinfo.main_char_id:
                if character.api_id == api_id:
                    # TODO: Remove services also
                    if authinfo.is_blue:
                        logger.debug("Blue user %s deleting api for main character. Disabling." % request.user)
                        disable_blue_member(request.user)
                    else:
                        logger.debug("User %s deleting api for main character. Disabling." % request.user)
                        disable_member(request.user, authinfo.main_char_id)

    EveManager.delete_api_key_pair(api_id, request.user.id)
    EveManager.delete_characters_by_api_id(api_id, request.user.id)
    logger.info("Succesfully processed api delete request by user %s for api %s" % (request.user, api_id))
    return HttpResponseRedirect("/api_key_management/")
Пример #19
0
def main_character_change(request, char_id):
    logger.debug("main_character_change called by user %s for character id %s" % (request.user, char_id))
    if EveManager.check_if_character_owned_by_user(char_id, request.user):
        previousmainid = AuthServicesInfoManager.get_auth_service_info(request.user).main_char_id
        AuthServicesInfoManager.update_main_char_Id(char_id, request.user)
        # Check if character is in the alliance
        character_info = EveManager.get_character_by_id(char_id)
        corporation_info = EveManager.get_corporation_info_by_id(character_info.corporation_id)
        logger.debug("User %s changing main character to %s in corp %s" % (request.user, character_info, corporation_info))
        if (settings.IS_CORP and EveManager.get_charater_corporation_id_by_id(char_id) == settings.CORP_ID) or (not settings.IS_CORP and EveManager.get_charater_alliance_id_by_id(char_id) == settings.ALLIANCE_ID):
            add_member_permission(request.user, 'member')
            add_user_to_group(request.user, settings.DEFAULT_AUTH_GROUP)
            add_user_to_group(request.user,
                              generate_corp_group_name(EveManager.get_character_by_id(char_id).corporation_name))
            logger.info("User %s transitioned to full member by chaning main character to %s" % (request.user, character_info))

        elif corporation_info != None:
            if corporation_info.is_blue:
                add_member_permission(request.user, 'blue_member')
                add_user_to_group(request.user, settings.DEFAULT_BLUE_GROUP)
                AuthServicesInfoManager.update_is_blue(True, request.user)
                logger.info("User %s transitioned to blue by changing main character to %s" % (request.user, character_info))
            else:
                if check_if_user_has_permission(request.user, 'member'):
                    disable_member(request.user, previousmainid)

                if check_if_user_has_permission(request.user, 'blue_member'):
                    disable_blue_member(request.user)
                logger.info("User %s disabled as new main character %s not member nor blue." % (request.user, character_info))
        else:
            # TODO: disable serivces
            if check_if_user_has_permission(request.user, 'member'):
                disable_member(request.user, previousmainid)

            if check_if_user_has_permission(request.user, 'blue_member'):
                disable_blue_member(request.user)
            logger.info("User %s disabled as new main character %s does not have corp model to check." % (request.user, character_info))

        return HttpResponseRedirect("/characters")
    return HttpResponseRedirect("/characters")
Пример #20
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))
Пример #21
0
def api_key_management_view(request):
    logger.debug("api_key_management_view called by user %s" % request.user)
    context = {"apikeypairs": EveManager.get_api_key_pairs(request.user.id)}

    return render_to_response("registered/apikeymanagment.html", context, context_instance=RequestContext(request))
Пример #22
0
def api_key_management_view(request):
    context = {'apikeypairs': EveManager.get_api_key_pairs(request.user.id)}

    return render_to_response('registered/apikeymanagment.html', context,
                              context_instance=RequestContext(request))
Пример #23
0
def characters_view(request):
    render_items = {'characters': EveManager.get_characters_by_owner_id(request.user.id),
                    'authinfo': AuthServicesInfoManager.get_auth_service_info(request.user)}
    return render_to_response('registered/characters.html', render_items, context_instance=RequestContext(request))