o
    6]hc	                     @   s   d dl mZ ddl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G dd dejZdS )    )serializers   )NotificationNotificationCategoryNotificationTagSiteStatisticc                   @      e Zd ZG dd dZdS )NotificationCategorySerializerc                   @      e Zd ZeZg dZdS )z#NotificationCategorySerializer.Meta)idnamedescription
color_codeN)__name__
__module____qualname__r   modelfields r   r   ./var/www/apihucms/notifications/serializers.pyMeta       r   Nr   r   r   r   r   r   r   r   r	          r	   c                   @   r   )NotificationTagSerializerc                   @   s   e Zd ZeZddgZdS )zNotificationTagSerializer.Metar   r   N)r   r   r   r   r   r   r   r   r   r   r      r   r   Nr   r   r   r   r   r      r   r   c                   @   H   e Zd ZdZeddZe Ze Z	G dd dZ
dd Zdd	 Zd
S )NotificationListSerializerz3Serializer for listing notifications (minimal data)T	read_onlyc                   @   r
   )zNotificationListSerializer.Meta)
r   titler   slugpublished_datedatecategorypriorityis_featuredtagsNr   r   r   r   r   r   r   r   r   r   r      r   r   c                 C   s   dd |j  D S )Nc                 S   s   g | ]}|j jqS r   )tagr   .0r(   r   r   r   
<listcomp>   s    z7NotificationListSerializer.get_tags.<locals>.<listcomp>)notification_tagsallselfobjr   r   r   get_tags   s   z#NotificationListSerializer.get_tagsc                 C      |j S Nformatted_dater.   r   r   r   get_date!      z#NotificationListSerializer.get_dateNr   r   r   __doc__r	   r#   r   SerializerMethodFieldr&   r"   r   r1   r6   r   r   r   r   r      s    
r   c                   @   r   )NotificationDetailSerializerz)Serializer for detailed notification viewTr   c                   @   r
   )z!NotificationDetailSerializer.Meta)r   r   r   contentr    r!   r"   r#   r$   r%   external_link
attachmentmeta_descriptionr&   
created_at
updated_atNr'   r   r   r   r   r   +   r   r   c                 C   s   t dd |j D ddjS )Nc                 S   s   g | ]}|j qS r   )r(   r)   r   r   r   r+   5   s    z9NotificationDetailSerializer.get_tags.<locals>.<listcomp>Tmany)r   r,   r-   datar.   r   r   r   r1   4   s   z%NotificationDetailSerializer.get_tagsc                 C   r2   r3   r4   r.   r   r   r   r6   7   r7   z%NotificationDetailSerializer.get_dateNr8   r   r   r   r   r;   %   s    
	r;   c                   @   r   )SiteStatisticSerializerc                   @   r
   )zSiteStatisticSerializer.Meta)r   r   valuer   iconorderN)r   r   r   r   r   r   r   r   r   r   r   <   r   r   Nr   r   r   r   r   rE   ;   r   rE   c                   @   s,   e Zd ZdZeddZeddZe	 Z
dS )#NotificationStatsResponseSerializerz8Combined response serializer for notifications and statsTrB   N)r   r   r   r9   r   notificationsrE   
statisticsr   	DictField
paginationr   r   r   r   rI   A   s
    

rI   N)rest_frameworkr   modelsr   r   r   r   ModelSerializerr	   r   r   r;   rE   
SerializerrI   r   r   r   r   <module>   s    