from django.core.management import BaseCommand

from books.models import Module
from portfolio.factories import ProjectFactory
from portfolio.models import ProjectEntry
from users.models import User


class Command(BaseCommand):
    def handle(self, *args, **options):
        self.stdout.write("Preparing projects")
        user = User.objects.get(username='rachel.green')
        self.stdout.write("Deleting all projects")
        for project in user.projects.all():
            project.delete()

        self.stdout.write("Creating new project")
        project = ProjectFactory(
            title='Groot',
            description='I am Groot',
            student=user,
            objectives='Be Groot\nBe awesome'
        )

        self.stdout.write("Creating project entries")
        ProjectEntry.objects.create(
            activity='Kill Thanos',
            reflection='He sucks',
            next_steps='Go for the head',
            project=project
        )

        ProjectEntry.objects.create(
            activity='Grow up again',
            reflection='Being a teenager sucks',
            next_steps='Grow',
            project=project
        )
