Hey guys,
in my current project I need to perform some checks before showing a form
to the user. I'm not sure if I've done this in the best possible way. It
looks a bit complicated to me.
project = db.project(request.args(0))
step = db.project_step(request.args(1))
# Is the project existing?
if project:
# Is the current logged in user the owner of the project?
if auth.user_id == project.created_by:
# Is the step, we want to work with, existing?
if step:
tender_form = SQLFORM(db.tender)
else:
session.flash = T('Something went wrong.')
redirect(URL('project', 'show', args=request.args(0)))
else:
session.flash = T('Something went wrong.')
redirect(URL('project', 'show', args=request.args(0)))
else:
session.flash = T('Something went wrong.')
redirect(URL('default', 'index'))
I got three IFs what doesn't look elegant for me. Is it possible to combine
the IF project and IF step statements?
Thanks for your help
Andreas
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.