Automatically add new users to default groups
Review Request #7165 — Created April 4, 2015 and submitted — Latest diff uploaded
This change is to make a new user to be a member of default groups, when the user is registered or added to a local-site.
Works done are:
1. handle newly registered user
1) catch user_registered djblets.auth.signals.user_registered signal invoked when a new user is registered
2) add the new user to default groups
2. handle new LocalSite-User relation
1) catch m2m_changed (many-to-many relation changed) signal invoked when a LocalSite-User relation changed
2) invoke local_site_user_added for new relations between LocalSite and User
3) make a receiver of local_site_user_added, to add this newly added user to the LocalSite's default groups
Browser tests done:
- make new local site
- make new group, addign local the local site to it, and make it a default group
- make new group and addign local the local site to it (do not make it default group)
- add a user to the local site
- see if the user is added to group created in #2
- see if the user is not added to group created in #3
Unit Tests done:
- check if _add_default_groups signal handler is called properly when a user is registered
- check if _add_default_groups signal handler is called properly when local_site.users.add(user)
- check if _add_default_groups signal handler is called properly when user.local_site.add(local_site)
- check if _add_default_groups adds global default review_groups when a user is registered
- check if _add_default_groups adds a local_site's default groups when local_site.users.add(user) or user.local_site.add(local_site)
Edge cases:
- there's no default group
- there's no non-default group