-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from joshkel/master
Better support for custom user models
- Loading branch information
Showing
6 changed files
with
43 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import django | ||
from django.db import models | ||
try: | ||
from django.contrib.auth.models import AbstractBaseUser | ||
except ImportError: | ||
# Django 1.4 doesn't properly support custom user models, but a User is | ||
# close enough to AbstractBaseUser for our tests to work in 1.4. | ||
from django.contrib.auth.models import User as AbstractBaseUser | ||
|
||
|
||
class EmailUser(AbstractBaseUser): | ||
if django.VERSION >= (1, 5): | ||
# Skip on Django 1.4, since we're inheriting from User, which already | ||
# has an email address. | ||
email = models.CharField(max_length=254, unique=True) | ||
|
||
USERNAME_FIELD = 'email' | ||
|
||
def get_username(self): | ||
return self.email |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
[tox] | ||
envlist = py26, py27, py32, py33, py34, pypy | ||
envlist = py26-django14, py27, py32, py33, py34, pypy | ||
|
||
[testenv] | ||
deps = pytest | ||
deps = | ||
django14: django >=1.4.2,<1.5 | ||
pytest | ||
pytest-cov | ||
pytest-django-lite | ||
pytest-django | ||
commands = py.test --cov sudo --cov-report term-missing |