from django.db import models
from django.utils.translation import gettext_lazy as _


class TaskStatus(models.IntegerChoices):
    PENDING = 1, _("Pending")
    PROGRESS = 2, _("Progress")
    SUCCESSFUL = 3, _("Successful")
    FAILED = 4, _("Failed")
    CANCELED = 5, _("Canceled")

    @classmethod
    def get(cls, val):
        return dict(cls.choices).get(val)


class LogType(models.IntegerChoices):
    DEBUG = 0, _("Debug")
    PENDING = 1, _("Pending")
    PROGRESS = 2, _("Progress")
    SUCCESSFUL = 3, _("Successful")
    FAILED = 4, _("Failed")
    CANCELED = 5, _("Canceled")
    INFO = 6, _("Info")
    ERROR = 7, _("Error")

    @classmethod
    def get(cls, val):
        return dict(cls.choices).get(val)


COMPLETED_TASK_STATUSUS = [
    TaskStatus.SUCCESSFUL,
    TaskStatus.CANCELED,
]

PENDING_TASK_STATUSES = [
    TaskStatus.PENDING,
    TaskStatus.FAILED,
]
