This repository has been archived by the owner on Dec 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Auth user model changes #5
Open
AngryLawyer
wants to merge
7
commits into
master
Choose a base branch
from
auth-user-model-changes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
290f9c5
Added travis configuration
AngryLawyer ce0e821
Fixed issue where tests would not run in never versions of Django
AngryLawyer 2d9f831
Fixed unit test that was failing in 1.5.1 where setting a user role w…
AngryLawyer 643d27d
Should now support custom models safely without breaking older versions
AngryLawyer f31937f
Corrected bad import on old versions of django
AngryLawyer 9e83ae0
Tidied up the code slightly
AngryLawyer 77cc815
Updated version number
AngryLawyer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
language: python | ||
|
||
python: | ||
- "2.7" | ||
|
||
env: | ||
- DJANGO="django==1.5.1 --use-mirrors" | ||
- DJANGO="django==1.4.5 --use-mirrors" | ||
- DJANGO="django==1.3.7 --use-mirrors" | ||
|
||
install: | ||
- pip install $DJANGO | ||
- pip install milkman | ||
- export PYTHONPATH=. | ||
|
||
script: | ||
- python manage.py test userroles |
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
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,6 +1,41 @@ | ||
from django.db import models | ||
from userroles.models import UserRole | ||
import django.contrib.auth.models | ||
|
||
|
||
if hasattr(django.contrib.auth.models, 'AbstractBaseUser'): | ||
from django.contrib.auth.models import AbstractBaseUser, UserManager | ||
else: | ||
class AbstractBaseUser(object): | ||
pass | ||
|
||
class UserManager(object): | ||
pass | ||
|
||
|
||
class TestModeratorProfile(UserRole): | ||
stars = models.IntegerField() | ||
|
||
|
||
class TestUser(AbstractBaseUser): | ||
username = models.CharField(max_length=255, unique=True, db_index=True) | ||
email = models.EmailField(max_length=255, unique=True) | ||
first_name = models.CharField(max_length=255) | ||
surname = models.CharField(max_length=255) | ||
is_active = models.BooleanField(default=True) | ||
|
||
USERNAME_FIELD = 'username' | ||
REQUIRED_FIELDS = ['email', 'first_name', 'surname'] | ||
|
||
objects = UserManager() | ||
|
||
def get_full_name(self): | ||
#This is a required method | ||
return self.first_name + ' ' + self.surname | ||
|
||
def get_short_name(self): | ||
#This is a required method | ||
return self.email | ||
|
||
def __unicode__(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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would make sense to use
getattr(settings, 'AUTH_USER_MODEL', 'auth.User')
here instead of the branching.