Automatically add new users to default groups

Review Request #7165 — Created April 4, 2015 and submitted — Latest diff uploaded

Information

Review Board
master
5366233...

Reviewers

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:

  1. make new local site
  2. make new group, addign local the local site to it, and make it a default group
  3. make new group and addign local the local site to it (do not make it default group)
  4. add a user to the local site
  5. see if the user is added to group created in #2
  6. see if the user is not added to group created in #3

Unit Tests done:

  1. check if _add_default_groups signal handler is called properly when a user is registered
  2. check if _add_default_groups signal handler is called properly when local_site.users.add(user)
  3. check if _add_default_groups signal handler is called properly when user.local_site.add(local_site)
  4. check if _add_default_groups adds global default review_groups when a user is registered
  5. 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:

  1. there's no default group
  2. there's no non-default group