"""This module contains the tasks for the ``documents`` app"""

from celery.utils.log import get_task_logger

from mtp.celery import app

from .models import Document

logger = get_task_logger(__name__)  # pylint: disable=invalid-name

@app.task
def generate_images_from_pdf(document_pk):
    """Task that will generate images from a pdf file type

    Parameters
    ----------
    document_pk: str
        The ``Document`` PK we try to extract the images from

    Returns
    -------
    str
        The absolute path of the folder with the generated images,
        or None if the task is currently in progress

    Notes
    -----
    This task simply load the ``Document`` object and call the ``generate_images_from_pdf``
    method on it.

    """

    document = Document.objects.get(pk=document_pk)

    return document.generate_images_from_pdf(async=False)
