Exemple #1
0
def add_api(request):
    if request.method == 'POST':
        form = AddApiKeyForm(request.POST)
        form.user = request.user
        if form.is_valid():
            user_api = UserAPIKey()
            user_api.keyID = form.cleaned_data["keyID"]
            user_api.vCode = form.cleaned_data["vCode"]
            user_api.user = request.user
            user_api.save()

            members, corps = init_characters(request.user, form.characters)
            
            for corp in corps:
                corp.save()
            for member in members:
                member.save()
            
            update_user_accesses(request.user)
            
            logger.info('"%s" added new API Key %d' % (request.user, user_api.keyID))

            return redirect('/account/')
    else: # request.method == 'GET'
        form = AddApiKeyForm()

    data = {
        'form': form,
        'accessMask': required_access_mask(character=True)
    }

    return render_to_response('ecm/auth/add_api.html', data, Ctx(request))
Exemple #2
0
def edit_api(request, keyID):
    api = get_object_or_404(UserAPIKey, keyID=int(keyID))
    if api.user != request.user:
        return forbidden(request)

    if request.method == 'POST':
        form = EditApiKeyForm(request.POST)
        form.user = request.user
        if form.is_valid():
            api.vCode = form.cleaned_data["vCode"]
            api.is_valid = True
            api.save()

            members, corps = init_characters(request.user, form.characters)
            
            for member in members:
                member.save()
            for corp in corps:
                corp.save()
            
            update_user_accesses(request.user)
            
            logger.info('"%s" edited API Key %d' % (request.user, api.keyID))

            return redirect('/account/')
    else: # request.method == 'GET'
        form = EditApiKeyForm(initial={"keyID" : api.keyID, "vCode" : api.vCode})

    data = {
        'form': form,
        'request_path' : request.get_full_path(),
        'accessMask': required_access_mask(character=True)
    }
    return render_to_response('ecm/auth/edit_api.html', data, Ctx(request))
Exemple #3
0
                logger.info('activation email sent to "%s" for account "%s"' % (user.email, user))
                return render_to_response('ecm/auth/account_created.html',
                                          { 'form': form },
                                          context_instance=Ctx(request))
            except Exception, err:
                logger.error('Sending an activation email failed. Address: %s Account: %s'
                             % (user.email, user))
                return render_to_response('ecm/auth/account_mail_fail.html',
                                          { 'form': form,
                                            'error_reason' : "Error{0}".format(str(err))},
                                          context_instance=Ctx(request))

    else: # request.method == 'GET'
        form = AccountCreationForm()

    accessMask = required_access_mask(character=True)

    return render_to_response('ecm/auth/create_account.html',
                              { 'form': form, 'accessMask': accessMask },
                              context_instance=Ctx(request))

#------------------------------------------------------------------------------
def activate_account(request, activation_key):
    try:
        user = RegistrationProfile.objects.activate_user(activation_key)
        update_user_accesses(user)
        logger.info('account "%s" activated' % (user.username))
        return render_to_response('ecm/auth/account_activated.html',
                                  { 'activated_user' : user },
                                  context_instance=Ctx(request))
    except (ValueError, UserWarning), err:
Exemple #4
0
                                          context_instance=Ctx(request))
            except Exception, err:
                logger.error(
                    'Sending an activation email failed. Address: %s Account: %s'
                    % (user.email, user))
                return render_to_response(
                    'ecm/auth/account_mail_fail.html', {
                        'form': form,
                        'error_reason': "Error{0}".format(str(err))
                    },
                    context_instance=Ctx(request))

    else:  # request.method == 'GET'
        form = AccountCreationForm()

    accessMask = required_access_mask(character=True)

    return render_to_response('ecm/auth/create_account.html', {
        'form': form,
        'accessMask': accessMask
    },
                              context_instance=Ctx(request))


#------------------------------------------------------------------------------
def activate_account(request, activation_key):
    try:
        user = RegistrationProfile.objects.activate_user(activation_key)
        update_user_accesses(user)
        logger.info('account "%s" activated' % (user.username))
        return render_to_response('ecm/auth/account_activated.html',