from django.core.management.base import BaseCommand, CommandError
from django.db.utils import IntegrityError
from apps.authentication.models import User, Role


class Command(BaseCommand):
    def handle(self, *args, **options):
        try:

            User.objects.create_superuser(
                email='<EMAIL>',
                password='<PASSWORD>',
                name='analyst',
                last_name='analyst',
                is_active=True,
                role=Role.objects.get(name='Analyst')
            )

            User.objects.create_superuser(
                email='<EMAIL>',
                password='<PASSWORD>',
                name='task',
                last_name='distributor',
                is_active=True,
                role=Role.objects.get(name='Task distributor')
            )

            User.objects.create_superuser(
                email='<EMAIL>',
                password='<PASSWORD>',
                name='task',
                last_name='creator',
                is_active=True,
                role=Role.objects.get(name='Task creator')
            )

            User.objects.create_superuser(
                email='<EMAIL>',
                password='<PASSWORD>',
                name='task',
                last_name='executor',
                is_active=True,
                role=Role.objects.get(name='Task executor')
            )

        except IntegrityError:
            print("User with this email already exists.")

from django.core.management.base import BaseCommand, CommandError
from django.db.utils import IntegrityError
from apps.authentication.models import User, Role


class Command(BaseCommand):
    def handle(self, *args, **options):
        try:

            User.objects.create_superuser(
                email='<EMAIL>',
                password='<PASSWORD>',
                name='analyst',
                last_name='analyst',
                is_active=True,
                role=Role.objects.get(name='Analyst')
            )

            User.objects.create_superuser(
                email='<EMAIL>',
                password='<PASSWORD>',
                name='task',
                last_name='distributor',
                is_active=True,
                role=Role.objects.get(name='Task distributor')
            )

            User.objects.create_superuser(
                email='<EMAIL>',
                password='<PASSWORD>',
                name='task',
                last_name='creator',
                is_active=True,
                role=Role.objects.get(name='Task creator')
            )

            User.objects.create_superuser(
                email='<EMAIL>',
                password='<PASSWORD>',
                name='task',
                last_name='executor',
                is_active=True,
                role=Role.objects.get(name='Task executor')
            )

        except IntegrityError:
            print("User with this email already exists.")
