from django.core.management.base import BaseCommand
from users.models import User # Assuming your custom user model is named User in users.models

class Command(BaseCommand):
    help = 'Creates a superuser if one does not already exist with email admin@admin.com'

    def handle(self, *args, **options):
        email = 'admin2@admin.com'

        if not User.objects.filter(email=email).exists():
            User.objects.create_superuser(
                email=email,
                role='admin',  
                password='string', 
                is_staff=True,
                is_superuser=True,
                full_name='Admin User' # Assuming fullname is a CharField or TextField
            )
            self.stdout.write(self.style.SUCCESS(f'Successfully created superuser with email {email} and id {User.objects.get(email=email).id}'))
        else:
            self.stdout.write(self.style.SUCCESS(f'Superuser with email {email} already exists.'))
