U
    Vc
                     @   s   d dl mZ d dlmZmZ d dlmZ d dlm	Z	 ddl
mZ ddlmZ G dd	 d	ejZG d
d dejZG dd dejZG dd dejZG dd dejZdS )    )serializers)MinValueValidatorMaxValueValidator
validators)IncludeExcludeOnlyValidator   )PublicResourcefile_validatorc                   @   s@   e Zd ZejddZejddZejddZe Z	dd Z
dS ) AddPublicResourceInputSerializer  
max_length,     c                 C   s   t | |S Nr
   )selfdata r   8/var/www/wikiazma_server/public_resources/serializers.pyvalidate   s    z)AddPublicResourceInputSerializer.validateN)__name__
__module____qualname__r   	CharFieldtokentitle	file_type	FileFieldfiler   r   r   r   r   r      s
   r   c                   @   s4   e Zd ZejddZejddZejejgdZ	dS )!EditPublicResourceInputSerializerr   r   r   r   N)
r   r   r   r   r   r   r   main_validatorsuuid_validatorZpublic_resources_idr   r   r   r   r!      s
   r!   c                   @   s    e Zd ZejddZe ZdS )#DeletePublicResourceInputSerializerr   r   N)r   r   r   r   r   r   srcr   r   r   r   r$      s   r$   c                   @   s   e Zd ZejddZejddddZejdddZejdddZej	e
d	gd
Zej	e
dedgd
Zeje gd
Zdd ZdS )!PublicResourceListInputSerializerr   r   d   FT)r   required
allow_nullr   )r   r(   r   r   r   c                 C   s.   ddddg}||kr*t dd| |S )N	title_asc
title_desccreated_at_asccreated_at_desczsort_by should be one of z, )r   ValidationErrorjoin)r   valueZallowed_sort_by_itemsr   r   r   validate_sort_by.   s       z2PublicResourceListInputSerializer.validate_sort_byN)r   r   r   r   r   r   qfile_type_qsort_byIntegerFieldr   skipr   taker   deleted_filterr1   r   r   r   r   r&   #   s   r&   c                   @   s^   e Zd Ze Ze Ze ZejddZ	ejddZ
ejddZdd ZG dd dZdS )PublicResourceModelSerializerfile_url)method_namec                 C   s   |j jS r   )r    url)r   instancer   r   r   r:   E   s    z&PublicResourceModelSerializer.file_urlc                   @   s    e Zd ZeZddddddgZdS )z"PublicResourceModelSerializer.Metaidr   r   linkr<   thumbN)r   r   r   r	   modelfieldsr   r   r   r   MetaH   s   rC   N)r   r   r   r   r   r>   r   r   SerializerMethodFieldr?   r<   r@   r:   rC   r   r   r   r   r9   :   s   r9   N)rest_frameworkr   Zdjango.core.validatorsr   r   utilsr   r"   utils.validatorsr   modelsr	   r   
Serializerr   r!   r$   r&   ModelSerializerr9   r   r   r   r   <module>   s   