"""This module contains the models for the ``saba`` discrete_app"""

from django.db import models
from django.utils.functional import cached_property
from django.utils.translation import ugettext_lazy as _

from mtp.apps.assessments.models import CertificationProgramUserStatus
from mtp.apps.tasks.models import DjangoTask


class CertificationProgramUserStatusDjangoTask(DjangoTask):
    """Django model representing CertificationProgramUserStatus related task

    This task inherits from ``DjangoTask`` and adds a relation to a
    ``CertificationProgramUserStatus``.

    Attributes
    ----------
    certification : django ``ForeignKey``
        Foreign key to the ``CertificationProgramUserStatus`` being synced.

    """

    certification = models.ForeignKey(
        CertificationProgramUserStatus,
        verbose_name=_('CertificationProgramUserStatus'),
        related_name='tasks',
        on_delete=models.CASCADE
    )

    @cached_property
    def redis_model(self):
        """Returns the redis_model linked to this django model"""

        from .redis_models import SabaLimpydTask

        return SabaLimpydTask
