Full-House-UW/fullhouse — pull request #129 by jlowdermilk (2012-11-18 03:27:00+00:00)
Title: Script to migrate existing users to new email-only users

This is a standalone tool and can be merged before or after #126, although it has some requirements to run (see requirements below. This is a one-time script to update the user models for existing users in prod to use the new email-based authentication model.

Script behavior is as follows:

Look at all users. If multiple users share an email, the first to register that email keeps it, and later users are assigned an equivalent email generated as `email_name+username@domain`. An email is then sent to each user whose email has been changed informing them of the change.

Requires:
`django-email-as-username` must be installed (with pip), and `settings/local.py` should be edited to add the tools directory to TEMPLATE_DIRS so the templates for the email header and message can be loaded.

Usage:
To run the migration script run `./manage.py shell`. This opens the django-admin commandline. Type the following commands in and hit enter:
```python
from tools import migrate_fullhouse_usernames
migrate_fullhouse_usernames
```
If all succeeds you will see a message displaying counts of duplicated users patched and a message saying all usernames were successfully migrated