Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomdieu committed Jun 4, 2023
1 parent f7478e6 commit 23b2cd5
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions soils_management/core/management/commands/admin_default_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,26 @@
from core.models import Soil, SoilArea

User = get_user_model()


class Command(BaseCommand):
help = 'création d\'un admin par défaut pour vous permettre de visulaisé vos sols par zone sur la carte et d\'en ajouter de nouvelles'
help = "création d'un admin par défaut pour vous permettre de visulaisé vos sols par zone sur la carte et d'en ajouter de nouvelles"

def add_arguments(self, parser):
pass

def handle(self, *args, **options):
print()
admin = User.objects.create_user(username='soilAdmin', email='soilAdmin@gmail.com', password='12345678')
admin.is_staff = True
admin.is_superuser = True
admin.save()
self.stdout.write(self.style.SUCCESS(f'an admin user by default with the username {admin.get_username()} was created'))
print()
if not User.objects.filter(username="soilAdmin").exists():
admin = User.objects.create_user(
username="soilAdmin", email="soilAdmin@gmail.com", password="12345678"
)
admin.is_staff = True
admin.is_superuser = True
admin.save()
self.stdout.write(
self.style.SUCCESS(
f"an admin user by default with the username {admin.get_username()} was created"
)
)
print()

0 comments on commit 23b2cd5

Please sign in to comment.