Ejemplo n.º 1
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)
        messages.success(request, 'Changed main character ID to %s' % char_id)
        set_state(request.user)
        return redirect("auth_characters")
    messages.error(request, 'Failed to change main character - selected character is not owned by your account.')
    return redirect("auth_characters")
Ejemplo n.º 2
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 EveCharacter.objects.filter(character_id=char_id).exists() and EveCharacter.objects.get(
            character_id=char_id).user == request.user:
        AuthServicesInfoManager.update_main_char_id(char_id, request.user)
        messages.success(request, _('Changed main character ID to %(charid)s') % {"charid": char_id})
        set_state(request.user)
        return redirect("auth_dashboard")
    messages.error(request, _('Failed to change main character - selected character is not owned by your account.'))
    return redirect("auth_characters")
Ejemplo n.º 3
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 EveCharacter.objects.filter(character_id=char_id).exists() and EveCharacter.objects.get(
            character_id=char_id).user == request.user:
        AuthServicesInfoManager.update_main_char_id(char_id, request.user)
        messages.success(request, 'Changed main character ID to %s' % char_id)
        set_state(request.user)
        return redirect("auth_dashboard")
    messages.error(request, 'Failed to change main character - selected character is not owned by your account.')
    return redirect("auth_characters")
Ejemplo n.º 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 = AuthServicesInfo.objects.get(user=request.user)
    EveManager.delete_api_key_pair(api_id, request.user.id)
    EveManager.delete_characters_by_api_id(api_id, request.user.id)
    messages.success(request, 'Deleted API key %s' % api_id)
    logger.info("Succesfully processed api delete request by user %s for api %s" % (request.user, api_id))
    if not EveCharacter.objects.filter(character_id=authinfo.main_char_id).exists():
        authinfo.main_char_id = None
        authinfo.save()
        set_state(request.user)
    return redirect("auth_dashboard")
Ejemplo n.º 5
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 = AuthServicesInfo.objects.get(user=request.user)
    EveManager.delete_api_key_pair(api_id, request.user.id)
    EveManager.delete_characters_by_api_id(api_id, request.user.id)
    messages.success(request, _('Deleted API key %(apiid)s') % {"apiid": api_id})
    logger.info("Succesfully processed api delete request by user %s for api %s" % (request.user, api_id))
    if not EveCharacter.objects.filter(character_id=authinfo.main_char_id).exists():
        authinfo.main_char_id = ''
        authinfo.save()
        set_state(request.user)
    return redirect("auth_dashboard")
Ejemplo n.º 6
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 = AuthServicesInfo.objects.get_or_create(user=request.user)[0]
    EveManager.delete_api_key_pair(api_id, request.user.id)
    EveManager.delete_characters_by_api_id(api_id, request.user.id)
    messages.success(request, 'Deleted API key %s' % api_id)
    logger.info("Succesfully processed api delete request by user %s for api %s" % (request.user, api_id))
    if EveCharacter.objects.filter(character_id=authinfo.main_char_id).exists():
        return redirect("auth_api_key_management")
    else:
        authinfo.main_char_id = None
        authinfo.save()
        set_state(request.user)
        return redirect("auth_characters")
Ejemplo n.º 7
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)
        messages.success(request, 'Changed main character ID to %s' % char_id)
        set_state(request.user)
        return redirect("auth_characters")
    messages.error(
        request,
        'Failed to change main character - selected character is not owned by your account.'
    )
    return redirect("auth_characters")
Ejemplo n.º 8
0
def user_refresh_api(request, api_id):
    logger.debug("user_refresh_api called by user %s for api id %s" % (request.user, api_id))
    if EveApiKeyPair.objects.filter(api_id=api_id).exists():
        api_key_pair = EveApiKeyPair.objects.get(api_id=api_id)
        if api_key_pair.user == request.user:
            refresh_api(api_key_pair)
            messages.success(request, 'Refreshed API key %s' % api_id)
            set_state(request.user)
        else:
            messages.warning(request, 'You are not authorized to refresh that API key.')
            logger.warn("User %s not authorized to refresh api id %s" % (request.user, api_id))
    else:
        messages.warning(request, 'Unable to locate API key %s' % api_id)
        logger.warn("User %s unable to refresh api id %s - api key not found" % (request.user, api_id))
    return redirect("auth_api_key_management")
Ejemplo n.º 9
0
def user_refresh_api(request, api_id):
    logger.debug("user_refresh_api called by user %s for api id %s" % (request.user, api_id))
    if EveApiKeyPair.objects.filter(api_id=api_id).exists():
        api_key_pair = EveApiKeyPair.objects.get(api_id=api_id)
        if api_key_pair.user == request.user:
            refresh_api(api_key_pair)
            messages.success(request, 'Refreshed API key %s' % api_id)
            set_state(request.user)
        else:
            messages.warning(request, 'You are not authorized to refresh that API key.')
            logger.warn("User %s not authorized to refresh api id %s" % (request.user, api_id))
    else:
        messages.warning(request, 'Unable to locate API key %s' % api_id)
        logger.warn("User %s unable to refresh api id %s - api key not found" % (request.user, api_id))
    return redirect("auth_dashboard")
Ejemplo n.º 10
0
def user_refresh_api(request, api_id):
    logger.debug("user_refresh_api called by user %s for api id %s" % (request.user, api_id))
    if EveApiKeyPair.objects.filter(api_id=api_id).exists():
        api_key_pair = EveApiKeyPair.objects.get(api_id=api_id)
        if api_key_pair.user == request.user:
            refresh_api.apply(args=(api_key_pair,))
            messages.success(request, _('Refreshed API key %(apiid)s') % {"apiid": api_id})
            set_state(request.user)
        else:
            messages.warning(request, _('You are not authorized to refresh that API key.'))
            logger.warn("User %s not authorized to refresh api id %s" % (request.user, api_id))
    else:
        messages.warning(request, _('Unable to locate API key %(apiid)s') % {"apiid": api_id})
        logger.warn("User %s unable to refresh api id %s - api key not found" % (request.user, api_id))
    return redirect("auth_dashboard")
Ejemplo n.º 11
0
def pre_save_user(sender, instance, *args, **kwargs):
    logger.debug("Received pre_save from %s" % instance)
    # check if user is being marked active/inactive
    if not instance.pk:
        # new model being created
        return
    try:
        old_instance = User.objects.get(pk=instance.pk)
        if old_instance.is_active and not instance.is_active:
            logger.info("Disabling services for inactivation of user %s" % instance)
            disable_user(instance)
        elif instance.is_active and not old_instance.is_active:
            logger.info("Assessing state of reactivated user %s" % instance)
            set_state(instance)
    except User.DoesNotExist:
        pass
Ejemplo n.º 12
0
def pre_save_user(sender, instance, *args, **kwargs):
    logger.debug("Received pre_save from %s" % instance)
    # check if user is being marked active/inactive
    if not instance.pk:
        # new model being created
        return
    try:
        old_instance = User.objects.get(pk=instance.pk)
        if old_instance.is_active and not instance.is_active:
            logger.info("Disabling services for inactivation of user %s" % instance)
            disable_user(instance)
        elif instance.is_active and not old_instance.is_active:
            logger.info("Assessing state of reactivated user %s" % instance)
            set_state(instance)
    except User.DoesNotExist:
        pass
Ejemplo n.º 13
0
def refresh_user_apis(user):
    logger.debug('Refreshing all APIs belonging to user %s' % user)
    apis = EveApiKeyPair.objects.filter(user=user)
    for x in apis:
        refresh_api(x)
    # Check our main character
    auth = AuthServicesInfo.objects.get_or_create(user=user)[0]
    if auth.main_char_id:
        if EveCharacter.objects.filter(character_id=auth.main_char_id).exists() is False:
            logger.info(
                "User %s main character id %s missing model. Clearning main character." % (user, auth.main_char_id))
            auth.main_char_id = ''
            auth.save()
            notify(user, "Main Character Reset",
                   message="Your specified main character no longer has a model.\nThis could be the result of "
                           "an invalid API.\nYour main character ID has been reset.",
                   level="warn")
    set_state(user)
Ejemplo n.º 14
0
def refresh_user_apis(pk):
    user = User.objects.get(pk=pk)
    logger.debug('Refreshing all APIs belonging to user %s' % user)
    apis = EveApiKeyPair.objects.filter(user=user)
    for x in apis:
        refresh_api.apply(args=(x,))
    # Check our main character
    auth = AuthServicesInfo.objects.get(user=user)
    if auth.main_char_id:
        if EveCharacter.objects.filter(character_id=auth.main_char_id).exists() is False:
            logger.info(
                "User %s main character id %s missing model. Clearning main character." % (user, auth.main_char_id))
            auth.main_char_id = ''
            auth.save()
            notify(user, "Main Character Reset",
                   message="Your specified main character no longer has a model.\nThis could be the result of "
                           "an invalid API.\nYour main character ID has been reset.",
                   level="warn")
    set_state(user)