Thanks Alan. Since, I am a beginner, I will study the mentioned chapters 
and would try. In case of any problem, I will revert back.

@ 黄祥, I gave it a quick try, In this case when has_membership is True, all 
of the rows in the grid are editable. My requirement is to get few rows of 
the grid editable.

Please note, I hard coded the has_membership to True, I was not able to run 
the provided code as it is. I will try again and see if the provided code 
runs and I am getting the expected results.

On Sunday, March 24, 2013 3:45:48 AM UTC+5:30, 黄祥 wrote:
>
> why not use default auth user table and use editable and deletable on your 
> grid?
>
> e.g.
> *db.py*
> auth.settings.extra_fields['auth_user']=[
>     Field('gender', 'list:string', notnull=True),
>     Field('address', 'text', notnull=True),
>     Field('zip', length=10, notnull=True),
>     Field('city', length=10, notnull=True),
>     Field('country', length=10, notnull=True),
>     Field('phone', length=10, notnull=True, unique=True),
>     Field('company', 'reference company', notnull=True)]
>
> auth.define_tables(username=False, signature=True)
>
> from gluon.contrib.populate import populate
> if db(db.auth_user).isempty():
>
>     auth.add_group('Manager', 'Manager')
>     auth.add_group('Admin', 'Admin')
>     
>     auth.add_membership('1', '1')
>     auth.add_membership('2', '1')
>     auth.add_membership('2', '2')
>     
>     db.auth_user.bulk_insert([{'first_name' : 'Manager', 'last_name' : 
> 'Manager', 
>                                'email' : 'man...@test.com <javascript:>', 
>                                'password' : 
> db.auth_user.password.validate('password')[0],
>                                'gender' : 'Male', 'address' : 'Address', 
> 'zip' : '11111',
>                                'city' : 'Jakarta', 'country' : 
> 'Indonesia', 'phone' : '1',
>                                'company' : 1}, 
>                               {'first_name' : 'Admin', 'last_name' : 
> 'Admin', 
>                                'email' : 'ad...@test.com <javascript:>', 
>                                'password' : 
> db.auth_user.password.validate('password')[0],
>                                'gender' : 'Male', 'address' : 'Address', 
> 'zip' : '11111',
>                                'city' : 'Jakarta', 'country' : 
> 'Indonesia', 'phone' : '2',
>                                'company' : 1}])
>
> *default.py*
> @auth.requires_login()
> def rent():
>     has_membership=auth.has_membership('Manager')
>     grid=SQLFORM.grid(db.person, user_signature=False, 
>                       editable=has_membership, deletable=has_membership)
>     return locals()
>

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to