Esempio n. 1
0
def login(context, request):
    referrer = request.url
    if referrer == '/login.html':
        referrer = '/'  # never use the login form itself as came_from
    came_from = request.params.get('came_from', referrer)
    logging.debug("views.py::login Logging in...")
    if 'login' in request.POST.keys():
        login = request.params['login']
        password = request.params['password']
        accounts = context['accounts']
        #import pdb; pdb.set_trace()
        if password and accounts.has_key(login) and str(password) == str(
                accounts.get(login).password):
            headers = remember(request, login)
            logging.debug("views.py::login : Login OK.")
            return HTTPFound(location=came_from, headers=headers)
    master = get_template('templates/master.pt')
    logged_in = authenticated_userid(request)
    return rtr(
        'templates/login.pt',
        context=context,
        request=request,
        master=master,
        message='',
        logged_in=logged_in,
        came_from=came_from)
Esempio n. 2
0
def receive(context,request):
    logging.debug("Receiving Katz...")
    post = request.POST
    logged_in = authenticated_userid(request)
    accounts = context['accounts']
    errors={}
    message = ''
    master = get_template('templates/master.pt')
    if post.has_key('amount'):
        source = post.get('source','')    
        amount = post.get('amount','')
        target = accounts.get(logged_in)
	logging.debug("Source: %s Amount: %s Target: %s",source,amount,target)
        #errors = context['transactions'].isTransactionInvalid(source,logged_in,amount)
        if str(post.get('pin','')) != str(target.password):
	    logging.error("views.py::receive Invalid pin")
            errors['pin'] = 'invalid pin'

        try:
            tacc = accounts.get(logged_in)
            sacc = accounts.get(source)
            sacc.transfer(logged_in,amount)
            return rtr('templates/paid.pt',context=context,request=request,master=master,logged_in=logged_in,source=sacc,target=tacc,amount=amount,message=message)
        except Errors, e:
            errors.update(e.message)

        if errors:
            message= 'please correct the errors'
Esempio n. 3
0
def login(context, request):
    referrer = request.url
    if referrer == "/login.html":
        referrer = "/"  # never use the login form itself as came_from
    came_from = request.params.get("came_from", referrer)
    logging.debug("views.py::login Logging in...")
    if "login" in request.POST.keys():
        login = request.params["login"]
        password = request.params["password"]
        accounts = context["accounts"]
        # import pdb; pdb.set_trace()
        if password and accounts.has_key(login) and str(password) == str(accounts.get(login).password):
            headers = remember(request, login)
            logging.debug("views.py::login : Login OK.")
            return HTTPFound(location=came_from, headers=headers)
    master = get_template("templates/master.pt")
    logged_in = authenticated_userid(request)
    return rtr(
        "templates/login.pt",
        context=context,
        request=request,
        master=master,
        message="",
        logged_in=logged_in,
        came_from=came_from,
    )
Esempio n. 4
0
def transactions(context, request):
    master = get_template('templates/master.pt')
    logged_in = authenticated_userid(request)
    return rtr(
        'templates/transactions.pt',
        context=context,
        request=request,
        master=master,
        logged_in=logged_in,
        message=None)
Esempio n. 5
0
        try:
            source.transfer(target, amount)
            logging.debug("Sending katz successful")
        except Errors, e:
            errors.update(e.message)

        if len(errors):
            message = 'please correct the errors'
        else:
            return HTTPFound(location='/')

    master = get_template('templates/master.pt')
    return rtr(
        'templates/send.pt',
        context=context,
        request=request,
        master=master,
        logged_in=logged_in,
        message=message,
        errors=errors)


def receive(context, request):
    logging.debug("Receiving Katz...")
    post = request.POST
    logged_in = authenticated_userid(request)
    accounts = context['accounts']
    errors = {}
    message = ''
    master = get_template('templates/master.pt')
    if post.has_key('amount'):
        source = post.get('source', '')
Esempio n. 6
0
def index(context, request):
    master = get_template("templates/master.pt")
    logged_in = authenticated_userid(request)
    return rtr("templates/index.pt", context=context, request=request, master=master, logged_in=logged_in, message=None)