add admin from add_user command
This commit is contained in:
parent
472d61bdc2
commit
35bf1a65a2
2
reset.sh
2
reset.sh
|
@ -1,5 +1,5 @@
|
||||||
rm db/*
|
rm db/*
|
||||||
python3 manage.py migrate
|
python3 manage.py migrate
|
||||||
python3 manage.py add_institution Pangea
|
python3 manage.py add_institution Pangea
|
||||||
python3 manage.py add_user Pangea user@example.org 1234
|
python3 manage.py add_user Pangea user@example.org 1234 True
|
||||||
python3 manage.py up_snapshots example/snapshots/ user@example.org
|
python3 manage.py up_snapshots example/snapshots/ user@example.org
|
||||||
|
|
|
@ -14,19 +14,22 @@ class Command(BaseCommand):
|
||||||
parser.add_argument('institution', type=str, help='institution')
|
parser.add_argument('institution', type=str, help='institution')
|
||||||
parser.add_argument('email', type=str, help='email')
|
parser.add_argument('email', type=str, help='email')
|
||||||
parser.add_argument('password', type=str, help='password')
|
parser.add_argument('password', type=str, help='password')
|
||||||
|
parser.add_argument('is_admin', nargs='?', default=False, type=str, help='is admin')
|
||||||
|
|
||||||
def handle(self, *args, **kwargs):
|
def handle(self, *args, **kwargs):
|
||||||
email = kwargs['email']
|
email = kwargs['email']
|
||||||
password = kwargs['password']
|
password = kwargs['password']
|
||||||
|
is_admin = kwargs['is_admin']
|
||||||
institution = Institution.objects.get(name=kwargs['institution'])
|
institution = Institution.objects.get(name=kwargs['institution'])
|
||||||
self.create_user(institution, email, password)
|
self.create_user(institution, email, password, is_admin)
|
||||||
self.create_lot_tags()
|
self.create_lot_tags()
|
||||||
|
|
||||||
def create_user(self, institution, email, password):
|
def create_user(self, institution, email, password, is_admin):
|
||||||
self.u = User.objects.create(
|
self.u = User.objects.create(
|
||||||
institution=institution,
|
institution=institution,
|
||||||
email=email,
|
email=email,
|
||||||
password=password
|
password=password,
|
||||||
|
is_admin=is_admin,
|
||||||
)
|
)
|
||||||
self.u.set_password(password)
|
self.u.set_password(password)
|
||||||
self.u.save()
|
self.u.save()
|
||||||
|
|
Loading…
Reference in New Issue