Skip to content

Commit

Permalink
Merge pull request #5 from cmu-delphi/development
Browse files Browse the repository at this point in the history
Merge latest from development
  • Loading branch information
dmytrotsko authored Oct 10, 2024
2 parents afb7b14 + ea95742 commit 229164a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Empty file added src/base/management/__init__.py
Empty file.
Empty file.
19 changes: 19 additions & 0 deletions src/base/management/commands/initadmin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
from django.core.management.base import BaseCommand
from django.contrib.auth.models import User


ADMIN_USERNAME = os.environ.get("ADMIN_USERNAME", "admin") # Default username
ADMIN_EMAIL = os.environ.get("ADMIN_EMAIL", "admin@andrew.cmu.edu") # Default email
ADMIN_PASSWORD = os.environ.get("ADMIN_PASSWORD", "admin123") # Default password


class Command(BaseCommand):
help = "Automatically creates a superuser"

def handle(self, *args, **kwargs):
if not User.objects.filter(username=ADMIN_USERNAME).exists():
User.objects.create_superuser(ADMIN_USERNAME, ADMIN_EMAIL, ADMIN_PASSWORD)
self.stdout.write(self.style.SUCCESS("Superuser created successfully"))
else:
self.stdout.write(self.style.WARNING("Superuser already exists"))

0 comments on commit 229164a

Please sign in to comment.