[web2py] Re: Redirecting to user/profile?

2012-06-25 Thread RKS
I actually just decided that I probably just need to manually add new 
values to db.auth.users. That way this is actually a non-issue and I won't 
even need to worry about it.

I think it may be harder since I don't know how to do that, especially with 
the checks on if auth.user or IS_IN_DB references but I can't see this 
working any other way for what I want to do. The end goal is to take a 
checkout form that will submit like normal to the payment gateway but at 
the same time register users if they don't have accounts, not register 
users if they're logged in or the email value exists already in the 
auth.user db.

The code I have already in the controller is:

def checkout_test():
order = []
balance = 0
for product_id, qty, option_ids in session.cart:
products = db(db.product.id == product_id).select()
if products:
product = products[0]
options = [db.option[id] for id in option_ids]
total_price = qty * (product.price + sum([option.price for 
option in options]))
order.append((product_id, qty, total_price, product, options))
balance += total_price
else:
pass
session.balance = balance
if form.accepts(request, formname=None):
#if not auth.user:
#if field.email IS_NOT_IN_DB:
#register email field in auth.users db
   # pass
#pass
mail.send(to=['r...@rks.com','customer_email'],subject='Test 
Success',message=', '.join('%s: %s' % (k, v) for (k, v) in 
request.vars.iteritems()))
return dict(order=order, merchant_id=session.paypal_id)
elif form.errors:
return TABLE(*[TR(k, v) for k, v in form.errors.items()])

Of course, you'll notice some invalid code in there that I have as 
placeholders for myself to logically symbolize what I need done. 

-- 





[web2py] Re: Redirecting to user/profile?

2012-06-25 Thread Anthony
It may help if you show some code.

On Monday, June 25, 2012 5:04:03 PM UTC-4, RKS wrote:
>
> I'm having some issues I don't fully understand. I've customized an 
> auth.login using login_form.custom.widget.email etc in a controller. It 
> works fine and logs in users like you would expect.
>
> However, I have a view, checkout_test.html where I have included another 
> form=auth.register() in the controller. By default, a logged in user who 
> teis to access a page with auth.register() gets redirected to user/profile. 
>
> How can I stop this behavior on at least this one view? The reason this is 
> all here is that I'm extending the option to users on checkout to login or 
> create an account on successful checkout. So I'm trying to expose all the 
> auth.registration functions for non-logged in users. With the redirection, 
> these functions are preventing any logged in user from ever checking out.
>
> [SIDENOTE: I haven't been able to perfect my registering users on 
> successful checkout just yet so I could end up not having to include any 
> standard auth.register anything in this view once all is said and done.]
>

--