o
    Hi;                     @   s^   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
dS )    )serializers   )CPDConfiguration)Eventc                   @   s(   e Zd ZejdddZG dd dZdS )CPDConfigurationSerializerz
event.nameT)source	read_onlyc                   @   s    e Zd ZeZg dZddgZdS )zCPDConfigurationSerializer.Meta)idevent
event_name
cpd_points
created_at
updated_atr   r   N)__name__
__module____qualname__r   modelfieldsread_only_fields r   r   ;/var/www/html/smartRegister/backend/apps/cpd/serializers.pyMeta	   s    r   N)r   r   r   r   	CharFieldr   r   r   r   r   r   r      s    r   c                   @   2   e Zd ZejddZejdddddZdd Zd	S )
CPDExportRequestSerializerTrequired      F
max_digitsdecimal_placesr   
allow_nullc                 C   s    t jj|d std|S )N)r	   zEvent does not exist)r   objectsfilterexistsr   ValidationError)selfvaluer   r   r   validate_event_id   s   
z,CPDExportRequestSerializer.validate_event_idN)	r   r   r   r   IntegerFieldevent_idDecimalFieldr   r)   r   r   r   r   r          r   c                   @   r   )
BulkLookupRequestSerializerTr   r   r   Fr   c                 C   sJ   |j  }|ds|ds|dstd|jdkr#td|S )Nz.csvz.xlsxz.xlsz4File must be CSV or Excel format (.csv, .xlsx, .xls)i  P zFile size must be less than 5MB)namelowerendswithr   r&   size)r'   r(   filenamer   r   r   validate_file   s   



z)BulkLookupRequestSerializer.validate_fileN)	r   r   r   r   	FileFieldfiler,   r   r4   r   r   r   r   r.      r-   r.   N)rest_frameworkr   modelsr   apps.events.modelsr   ModelSerializerr   
Serializerr   r.   r   r   r   r   <module>   s    	
