potatolondon/djangae — pull request #71 by adamalton (2014-10-09 21:45:26+00:00)
Title: 49 - allow custom user models

This now provides the necessary User classes to allow 4 different ways of using auth:

1. Using Google Accounts authentication, on a normal SQL-ish database. Djangae provides a user model for this.
2. Using Google Accounts authentication, on a normal SQL-ish database, but customising the user model. Djangae provides an abstract user model for this.
3. Using Google Accounts authentication, on the Datastore. Djangae provides a user model with the nonrel-friendly PermissionsMixin for this.
4. Using Google Accounts authentication, on the Datastore with a custom user model. Djangae provides a user model with the nonrel-friendly PermissionsMixin for this. Djangae provides an abstract user model with the PermissionsMixin for this.

If `settings.AUTH_USER_MODEL` is set to one of our *concrete* user models, then we register it with the Django admin. Otherwise we let the app which is defining the custom user model to register it with the admin.

I added some basic tests.

I will update the documentation (by copy/pasting from this ticket) if you merge this :-).

We will need to change INSTALLED_APPS in djangae-testapp to point to 'djangae.contrib.gauth' when this is merged.

Disputable things:

* Arguably the user model for use case *4.* isn't necessary because you could just combine the other model classes yourself.
* Arguably the custom `GaeUserManager` class is unnecessary because people shouldn't be creating Google-Accounts-based User objects manually anyway, so there's no need to make `create_user` and `create_super_user` work (both the manager methods and the management commands).