barebone app with django and react, sse, jwt token, comport reader, test comport writer, requires com0com, users with groups, sample table vehicles, tokens for access and refresh
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from api.models import User
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Creates predefined admin user (username: admin, password: admin)'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
username = 'admin'
|
||||
password = 'admin'
|
||||
|
||||
if User.objects.filter(username=username).exists():
|
||||
self.stdout.write(
|
||||
self.style.WARNING(f'User "{username}" already exists')
|
||||
)
|
||||
return
|
||||
|
||||
user = User.objects.create(
|
||||
username=username,
|
||||
email='admin@scalesapp.com',
|
||||
role='employee',
|
||||
is_admin=True,
|
||||
is_staff=True,
|
||||
is_superuser=True,
|
||||
is_active=True
|
||||
)
|
||||
user.set_password(password)
|
||||
user.save()
|
||||
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(
|
||||
f'Successfully created admin user: {username} / {password}'
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user