o
    Mf1                     @   s   d Z ddlmZ ddlZddlmZ ddlmZm	Z	 ddl
mZ ddlmZ G dd	 d	eejZG d
d deejZG dd deejZG dd deZG dd deejZG dd dejZG dd dejZdS )zThis file and its contents are licensed under the Apache License 2.0. Please see the included NOTICE for copyright information and LICENSE for a copy of the license.
    )OrderedDictN)DynamicFieldsMixin)OrganizationOrganizationMember)serializers)UserSerializerc                   @      e Zd ZG dd dZdS )OrganizationIdSerializerc                   @      e Zd ZeZg dZdS )zOrganizationIdSerializer.Meta)idtitlecontact_infoN__name__
__module____qualname__r   modelfields r   r   h/var/www/html/analyze/labelStudio/lib/python3.10/site-packages/label_studio/organizations/serializers.pyMeta       r   Nr   r   r   r   r   r   r   r   r	          r	   c                   @   r   )OrganizationSerializerc                   @   s   e Zd ZeZdZdS )zOrganizationSerializer.Meta__all__Nr   r   r   r   r   r      s    r   Nr   r   r   r   r   r      r   r   c                   @   r   )OrganizationMemberSerializerc                   @   r
   )z!OrganizationMemberSerializer.Metar   organizationuserNr   r   r   r   r   r   r   r   r   r   r      r   r   Nr   r   r   r   r   r      r   r   c                   @   sF   e Zd ZejddZejddZdd Zdd ZG dd de	j
Z
d	S )
UserSerializerWithProjectsT)	read_onlyc                 C   s6   | j dds	d S | j d j}|jj|jdddS )Ncontributed_to_projectsFrequest)r   r   r   )contextgetr   created_projectsfilteractive_organizationvalues)selfr   current_userr   r   r   get_created_projects"   s   z/UserSerializerWithProjects.get_created_projectsc                 C   sZ   | j dds	d S | j d j}|jj|jddd}dd |D }t|}d	d |D S )
Nr#   Fr$   )project__organizationproject__idproject__titlec                 S   s(   g | ]}t |d  |d ddfqS )r/   r0   )r   r   r   )jsondumps).0pr   r   r   
<listcomp>1   s   ( zJUserSerializerWithProjects.get_contributed_to_projects.<locals>.<listcomp>c                 S   s   g | ]}t |qS r   )r1   loads)r3   keyr   r   r   r5   3   s    )r%   r&   r   annotationsr(   r)   r*   r   )r+   r   r,   projectscontributed_tor   r   r   get_contributed_to_projects)   s   z6UserSerializerWithProjects.get_contributed_to_projectsc                   @   s   e Zd Zejjd ZdS )zUserSerializerWithProjects.Meta)r'   r#   N)r   r   r   r   r   r   r   r   r   r   r   5   s    r   N)r   r   r   r   SerializerMethodFieldr'   r#   r-   r;   r   r   r   r   r   r   r!      s    r!   c                   @   s$   e Zd ZdZe ZG dd dZdS ) OrganizationMemberUserSerializerzAdds all user propertiesc                   @   r
   )z%OrganizationMemberUserSerializer.Metar   Nr    r   r   r   r   r   >   r   r   N)r   r   r   __doc__r!   r   r   r   r   r   r   r=   9   s    r=   c                   @   s$   e Zd ZejddZejddZdS )OrganizationInviteSerializerF)requiredN)r   r   r   r   	CharFieldtoken
invite_urlr   r   r   r   r?   C   s    r?   c                   @   s(   e Zd ZejdddZejdddZdS )OrganizationsParamsSerializerF)r@   defaultN)r   r   r   r   BooleanFieldactiver#   r   r   r   r   rD   H   s    rD   )r>   collectionsr   ujsonr1   drf_dynamic_fieldsr   organizations.modelsr   r   rest_frameworkr   users.serializersr   ModelSerializerr	   r   r   r!   r=   
Serializerr?   rD   r   r   r   r   <module>   s    
