U
    V _                     @   s   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	m
Z
mZmZ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 )    )Sum)serializers)CustomerListSerializer)UserProfile)ShotOperationPhonePhotoCustomerExamSeriec                   @   s"   e Zd ZG dd dZdd ZdS )ShotOperationSerializerc                   @   s   e Zd ZeZdZdS )zShotOperationSerializer.Meta__all__N)__name__
__module____qualname__r   modelfields r   r   3/var/www/html/iltdigicom/iltshot/api/serializers.pyMeta   s   r   c                 C   sD   t | jd | jd | jd | jd | jd | jd d}|  |S )Nshotoperation_nameshotoperation_typeshotoperation_debitcustomerphonecustomerprofile)r   r   r   r   r   r   )r   validated_datasave)selfshotoperationr   r   r   r      s    zShotOperationSerializer.saveN)r   r   r   r   r   r   r   r   r   r      s   r   c                   @   s.   e Zd ZejddZG dd dZdd ZdS )PhoneSerializercalculate_pictures_count)method_namec                   @   s   e Zd ZeZddddgZdS )zPhoneSerializer.Metaphone_id
phone_namephone_statepictures_countN)r   r   r   r   r   r   r   r   r   r   r       s   r   c                 C   sP   t jjddjddj|jdjddjtdd}|d	 d k	rH|d	 S d
S d S )NE)state)Zphone__state)Z	phone__idD)r   r   )total_debitr)   r   )r   objectsfilterid	aggregater   )r   instancedebitr   r   r   r    $   s    4z(PhoneSerializer.calculate_pictures_countN)r   r   r   r   SerializerMethodFieldr%   r   r    r   r   r   r   r      s   r   c                   @   s    e Zd Ze ZG dd dZdS )PhotoCustomerSerializerc                   @   s   e Zd ZeZddgZdS )zPhotoCustomerSerializer.Metar,   r   N)r   r   r   r   r   r   r   r   r   r   r   -   s   r   N)r   r   r   r   r   r   r   r   r   r   r1   +   s   r1   c                   @   s   e Zd ZG dd dZdS )SerieSerializerc                   @   s   e Zd ZeZddgZdS )zSerieSerializer.Meta
serie_code
serie_nameN)r   r   r   r
   r   r   r   r   r   r   r   2   s   r   N)r   r   r   r   r   r   r   r   r2   1   s   r2   c                   @   s&   e Zd ZedddZG dd dZdS )ExamSerializerT)	read_onlymanyc                   @   s   e Zd ZeZdddgZdS )zExamSerializer.Meta	exam_code	exam_nameseriesN)r   r   r   r	   r   r   r   r   r   r   r   9   s   r   N)r   r   r   r2   r:   r   r   r   r   r   r5   7   s   r5   N)django.db.modelsr   rest_frameworkr   customer.api.serializersr   account.modelsr   iltshot.modelsr   r   r   r	   r
   ModelSerializerr   r   r1   r2   r5   r   r   r   r   <module>   s   