Skip to content

Commit

Permalink
appliku scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
charlestang06 committed Aug 21, 2024
1 parent e290596 commit ebcc9b2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -e
python manage.py migrate
python manage.py makesuperuser
3 changes: 3 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -e
gunicorn iridisite.wsgi --log-file -
Empty file.
Empty file.
23 changes: 23 additions & 0 deletions tutoring_student/management/commands/makesuperuser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from django.utils.crypto import get_random_string
from django.core.management.base import BaseCommand
from django.contrib.auth import get_user_model

User = get_user_model()

class Command(BaseCommand):
def handle(self, *args, **options):
email = "admin@example.com"
new_password = get_random_string(10)
try:
if not User.objects.filter(is_superuser=True).exists():
User.objects.create_superuser(username="admin", email=email, password=new_password)
self.stdout.write("=======================")
self.stdout.write("Username: admin")
self.stdout.write(f"Email: {email}")
self.stdout.write(f"Password: {new_password}")
self.stdout.write("=======================")
else:
self.stdout.write("Superuser already exists. Skipping...")
except Exception as e:
self.stdout.write(str(e))
self.stdout.write("Failed to create superuser.")

0 comments on commit ebcc9b2

Please sign in to comment.