forked from DGNum/gestioCOF
Add testing helpers to create superuser
This commit is contained in:
parent
c239f28f17
commit
bd89dce11d
1 changed files with 11 additions and 1 deletions
|
@ -9,7 +9,9 @@ def _create_user(username, is_cof=False, is_staff=False, attrs=None):
|
|||
|
||||
password = attrs.pop('password', username)
|
||||
|
||||
user_keys = ['first_name', 'last_name', 'email', 'is_staff']
|
||||
user_keys = [
|
||||
'first_name', 'last_name', 'email', 'is_staff', 'is_superuser',
|
||||
]
|
||||
user_attrs = {k: v for k, v in attrs.items() if k in user_keys}
|
||||
|
||||
profile_keys = [
|
||||
|
@ -49,3 +51,11 @@ def create_member(username, attrs=None):
|
|||
|
||||
def create_staff(username, attrs=None):
|
||||
return _create_user(username, is_cof=True, is_staff=True, attrs=attrs)
|
||||
|
||||
|
||||
def create_root(username, attrs=None):
|
||||
if attrs is None:
|
||||
attrs = {}
|
||||
attrs.setdefault('is_staff', True)
|
||||
attrs.setdefault('is_superuser', True)
|
||||
return _create_user(username, attrs=attrs)
|
||||
|
|
Loading…
Reference in a new issue