Skip to content

Commit

Permalink
Merge pull request #113 from jproffitt/issue_112
Browse files Browse the repository at this point in the history
Prevent Historian group being added when creating superuser fixes #112
  • Loading branch information
jproffitt committed Sep 12, 2014
2 parents 0af4860 + dce1a75 commit d169d00
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fabric_bolt/accounts/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ def create_user(self, email, password=None, **kwargs):
user = super(DeployUserManager, self).create_user(email, password, **kwargs)

try:
# make sure there are no groups defined already.
user.groups.clear()
# just set as lowest level since we're not sure what you want.
user.groups.add(Group.objects.get(name='Historian'))
except Group.DoesNotExist:
Expand All @@ -19,6 +21,8 @@ def create_superuser(self, **kwargs):
user = super(DeployUserManager, self).create_superuser(**kwargs)

try:
# make sure there are no groups defined already.
user.groups.clear()
# Grab the admin group and assign it.
user.groups.add(Group.objects.get(name='Admin'))
except Group.DoesNotExist:
Expand Down
4 changes: 4 additions & 0 deletions fabric_bolt/accounts/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ def test_user_gravatar(self):
def test_createsuperuser(self):
user = DeployUser.objects.create_superuser(email='test@test.com', password='password')
self.assertTrue(user.user_is_admin())
self.assertFalse(user.user_is_deployer())
self.assertFalse(user.user_is_historian())

def test_createuser(self):
user = DeployUser.objects.create_user(email='test@test.com', password='password')
self.assertTrue(user.user_is_historian())
self.assertFalse(user.user_is_deployer())
self.assertFalse(user.user_is_admin())

0 comments on commit d169d00

Please sign in to comment.