This is the new code:
from gluon.fileutils import check_credentials
db.auth_group._common_filter=lambda query: \
(db.auth_group.org==session.org) *or check_credentials(request)*
I have tested check_credentials(request): it returns True - good!
But - sorry! - it did not solve the problem:
I think you want:
from gluon.fileutils import check_credentials
if not *check_credentials(request):*
* if not session.org: redirect('some_error_page')
* db.auth_group._common_filter=lambda query: (db.auth_group.org==
session.org)
On Tuesday, 21 August 2012 01:04:38 UTC-5, mweissen
Maybe I can say it in other words:
(1) If I am normal user, I should only see my part of the table and I can
work with it.
This is perfectly assured by
db.auth_group._common_filter=**lambda query: (db.auth_group.org==session.**
org http://session.org/)
(2) If I am the admin and if I use the
Now I understand better. Please open an issue for enhancement and link this
thread. For now you'll have to handle with the suggested logic or perhaps:
if *request.controller!='appadmin':*
* if not session.org: redirect('some_error_page')
* db.auth_group._common_filter=lambda query:
Done - thank you!
2012/8/21 Massimo Di Pierro massimo.dipie...@gmail.com
Now I understand better. Please open an issue for enhancement and link
this thread. For now you'll have to handle with the suggested logic or
perhaps:
if *request.controller!='appadmin':*
* if not session.org:
How do you set the common filter? Seems to me if session.org is not set,
the common filter should not be set. web2py cannot ignore it because it
does the wrong thing.
On Monday, 20 August 2012 11:41:41 UTC-5, mweissen wrote:
I have an application which should be used by some organizations.
You can do:
db.define_table(, common_filter = None if not session.org else (lambda
query:(db.my_table.org==session.org)))
you can also use the check:
from gluon.fileutils import check_credentials
check_credentials('admin') #returns true if you are logged as admin.
On Monday, 20 August
A little bit more code:
db.define_table('org',
Field('orgnr',
Field(shortname',
length=20,
requires=IS_LENGTH(maxsize=20,minsize=3)),
...
)
auth.settings.extra_fields['auth_group']=[
Field('org','reference org',
default=lambda: session.org,
Apologies
check_credentials(request)
instead of
check_credentials('admin')
On Monday, 20 August 2012 14:33:55 UTC-5, mweissen wrote:
A little bit more code:
db.define_table('org',
Field('orgnr',
Field(shortname',
length=20,
9 matches
Mail list logo