a
    Dgk                     @   sH   d dl mZ d dlmZ d dlmZ G dd deZG dd deZdS )	    )Field)BaseSerializer)get_full_urlc                   @   s    e Zd ZdZdd Zdd ZdS )DocumentDownloadUrlFieldz
    Serializes the "download_url" field for documents.

    Example:
    "download_url": "http://api.example.com/documents/1/my_document.pdf"
    c                 C   s   |S )N )selfinstancer   r   c/var/www/lab.imftr.de/x/nb_venv/lib/python3.9/site-packages/wagtail/documents/api/v2/serializers.pyget_attribute   s    z&DocumentDownloadUrlField.get_attributec                 C   s   t | jd |jS )Nrequest)r   contexturl)r   documentr   r   r	   to_representation   s    z*DocumentDownloadUrlField.to_representationN)__name__
__module____qualname____doc__r
   r   r   r   r   r	   r      s   r   c                   @   s   e Zd ZeddZdS )DocumentSerializerT)Z	read_onlyN)r   r   r   r   download_urlr   r   r   r	   r      s   r   N)Zrest_framework.fieldsr   Zwagtail.api.v2.serializersr   Zwagtail.api.v2.utilsr   r   r   r   r   r   r	   <module>   s   