"""This module provides the abstract ``IdeasActivity`` and ``Idea`` models for the ``ideas`` app"""

from django.conf import settings
from django.db import models
from django.utils.translation import ugettext_lazy as _

from django_extensions.db.models import TimeStampedModel
from orderable.models import Orderable

from mtp.apps.likes.models import Likeable
from mtp.apps.trainings.models import TrainingSession


class IdeasActivity(models.Model):
    """Django abstract model defining the base fields for the ``IdeasActivity`` models

    Attributes
    ----------
    is_anonymous: django ``BooleanField``, default to False
        If True, the authors of the ``Ideas`` of this activity won't be displayed.

    Notes
    -----
    This model is abstract

    """

    is_anonymous = models.BooleanField(
        default=False,
        verbose_name=_('Anonymous')
    )

    class Meta:
        abstract = True


class Idea(Likeable, Orderable, TimeStampedModel):
    """Django abstract model defining the base fields for the ``Idea`` models

    Attributes
    ----------
    user: django ``ForeignKey`` field to ``settings.AUTH_USER_MODEL``
        The author of this idea
    session: django ``ForeignKey`` field to ``TrainingSession``, Nullable
        The session this idea was made into.

    Notes
    -----
    This model is abstract

    """

    user = models.ForeignKey(
        settings.AUTH_USER_MODEL,
        related_name='%(class)s_ideas',
        null=True,
        blank=True,
        verbose_name=_('User')
    )
    session = models.ForeignKey(
        TrainingSession,
        related_name='%(class)s_ideas',
        verbose_name=_('Session'),
        null=True,
        blank=True
    )

    class Meta:
        abstract = True
