""" This module holds the factories for the ``brainstormers`` app. """

import factory

from mtp.apps.accounts.factories import TraineeFactory
from mtp.apps.trainings.factories import TrainingFactory, TrainingSessionFactory

from .models import (
    Brainstormer,
    BrainstormerProposition,
    BrainstormerPropositionGroup,
    BrainstormerTemplate
)


class BrainstormerTemplateFactory(factory.django.DjangoModelFactory):
    """ Factory for the ``mtp.apps.brainstormers.models.BrainstormerTemplate`` model.

    Attributes
    ----------
    name : ``factory.Sequence``
    training : sub-factory of ``mtp.apps.trainings.factories.TrainingFactory``

    """

    class Meta:
        model = BrainstormerTemplate

    name = factory.Sequence(lambda n: 'BrainstormerTemplate-%d' % n)
    training = factory.SubFactory(TrainingFactory)


class BrainstormerFactory(factory.django.DjangoModelFactory):
    """ Factory for the ``mtp.apps.brainstormers.models.Brainstormer`` model.

    Attributes
    ----------
    name : ``factory.Sequence``
    session : sub-factory of ``mtp.apps.trainings.factories.TrainingSessionFactory``

    """

    class Meta:
        model = Brainstormer

    name = factory.Sequence(lambda n: 'Brainstormer-%d' % n)
    session = factory.SubFactory(TrainingSessionFactory)


class BrainstormerPropositionGroupFactory(factory.django.DjangoModelFactory):
    """ Factory for the ``mtp.apps.brainstormers.models.BrainstormerPropositionGroup`` model.

    Attributes
    ----------
    name : ``factory.Sequence``
    brainstormer : sub-factory of ``mtp.apps.brainstormers.factories.BrainstormerFactory``

    """

    class Meta:
        model = BrainstormerPropositionGroup

    name = factory.Sequence(lambda n: 'Group-%d' % n)
    brainstormer = factory.SubFactory(BrainstormerFactory)


class BrainstormerPropositionFactory(factory.django.DjangoModelFactory):
    """ Factory for the ``mtp.apps.brainstormers.models.BrainstormerProposition`` model.

    Attributes
    ----------
    text : ``factory.Sequence``
    group : sub-factory of ``mtp.apps.brainstormers.factories.BrainstormerPropositionGroupFactory``
    user : sub-factory of ``mtp.apps.account.factories.TraineeFactory``

    """

    class Meta:
        model = BrainstormerProposition

    text = factory.Sequence(lambda n: 'Proposition-%d' % n)
    user = factory.SubFactory(TraineeFactory)
