--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-developers@googlegroups.com
unsubscribe: web2py-developers+unsubscribe@googlegroups.com
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hello Anthony,Thanks for answering... I have use case where user need to change role, for record input/review and approval... In a perfect world they wouldn't do that, but in real world we lack staff to do these differents activities...
So, deleting and adding records burns ID over time, it not a big deal, but it would be more logic to just update the actual role of the person... I can't use your first option as all the differents groups needs to exist at the same time obviously...
update_membership would also be performed in a signle operation instead of 2...
I can surely create my own method or function, but it would make more sens to include a update method in web2py from my stand point instead of subclassing auth in case I go with a method...
I will have a look at Auth code to see how I could mimic add_ and del_membership in a function, particularly how they update auth.user_groups, which is important to be up to date in the context as the UI change base on user role membership...
On Wednesday, July 26, 2017 at 11:04:32 AM UTC-4, Richard wrote:Hello Anthony,Thanks for answering... I have use case where user need to change role, for record input/review and approval... In a perfect world they wouldn't do that, but in real world we lack staff to do these differents activities...
Are you saying the same user must constantly rotate among multiple different roles?
That seems like a rare enough use case that we don't need to support it with a special method in the framework.
Instead of using auth_membership, have you considered just adding a "role" field to the auth_user table?
So, deleting and adding records burns ID over time, it not a big deal, but it would be more logic to just update the actual role of the person... I can't use your first option as all the differents groups needs to exist at the same time obviously...
I'm not sure what you mean by my "first option." My two suggestions are just use the delete and add methods, or write a custom function to update the existing record. I don't see how either approach creates a problem with different groups existing at the same time.
update_membership would also be performed in a signle operation instead of 2...
Sure, but both operations should be fairly fast. Is there a performance issue -- do you have a high load of role changes specifically?
I can surely create my own method or function, but it would make more sens to include a update method in web2py from my stand point instead of subclassing auth in case I go with a method...
Just write a function -- no need to go subclassing Auth just to be able to write auth.update_membership(...) instead of auth_update_membership(...).
I will have a look at Auth code to see how I could mimic add_ and del_membership in a function, particularly how they update auth.user_groups, which is important to be up to date in the context as the UI change base on user role membership...
Those functions include a lot of logic allowing you to alternatively specify the group_id or role name and to handle is_active when present. You could simplify the logic by constraining how you specify the arguments. auth.user_groups is just a dictionary, so very simple to update -- you can even just call auth.update_groups(), which will create the dictionary from scratch.
Anthony
Instead of using auth_membership, have you considered just adding a "role" field to the auth_user table?Could, but it already implemented a long time ago... And it would prevent the usage of auth.has_membership...
@auth.requires(auth.user.role == 'myrole')
IS_MYROLE = auth.user.role == 'myrole'
I'm not sure what you mean by my "first option." My two suggestions are just use the delete and add methods, or write a custom function to update the existing record. I don't see how either approach creates a problem with different groups existing at the same time.
I thougth you mention to just change group name...
Can you explain why your users must rotate among different memberships rather than simply having multiple simultaneous memberships? If a user can insert a record and one time and approve a record at another time, why not just give them insert and approve roles all the time rather than switch between the roles?
Anthony--
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-develop...@googlegroups.com.
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-develop...@googlegroups.com.
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-develop...@googlegroups.com.