import djclick as click

from vbv_lernwelt.assignment.models import Assignment, AssignmentCompletion
from vbv_lernwelt.core.constants import (
    TEST_COURSE_SESSION_BERN_ID,
    TEST_STUDENT1_USER_ID,
)
from vbv_lernwelt.core.models import User
from vbv_lernwelt.course.creators.test_course import (
    create_test_assignment_submitted_data,
)
from vbv_lernwelt.course.models import CourseCompletion, CourseSession
from vbv_lernwelt.notify.models import Notification


@click.command()
@click.option(
    "--create-completion/--no-create-completion",
    default=False,
    help="will create completion data for some users",
)
def command(create_completion):
    print("cypress reset data")
    CourseCompletion.objects.all().delete()
    Notification.objects.all().delete()
    AssignmentCompletion.objects.all().delete()
    User.objects.all().update(language="de")
    User.objects.all().update(additional_json_data={})

    if create_completion:
        print("create completion data for test course")
        create_test_assignment_submitted_data(
            assignment=Assignment.objects.get(
                slug="test-lehrgang-assignment-überprüfen-einer-motorfahrzeugs-versicherungspolice"
            ),
            course_session=CourseSession.objects.get(id=TEST_COURSE_SESSION_BERN_ID),
            user=User.objects.get(id=TEST_STUDENT1_USER_ID),
        )
