Ë
    	]jø  ã                   ó€   — d Z ddlZddlmZ ddlmZ ddlmZ  ej                  e	«      Z
 G d„ d«      Z G d„ d	«      Zy)
z¦This 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.
é    N)ÚQuerySet)Úcached_property)Úget_object_or_404c                   ó   — e Zd Zd„ Zy)ÚDummyModelMixinc                  ó   — y)NT© )ÚselfÚusers     úB/root/env/lib/python3.12/site-packages/label_studio/core/mixins.pyÚhas_permissionzDummyModelMixin.has_permission   s   € Øó    N)Ú__name__Ú
__module__Ú__qualname__r   r	   r   r   r   r      s   „ ór   r   c                   ó>   — e Zd ZdZdZdZdZed„ «       Zd„ Z	d„ Z
d„ Zy)ÚGetParentObjectMixinao  
    Mixin for nested resources that fetches the parent object from URL kwargs.

    Provides `self.parent_object` (cached) based on `parent_queryset`.

    Attributes:
        parent_queryset: QuerySet for the parent model (required)
        parent_lookup_field: Field to filter on (default: lookup_field, usually 'pk')
        parent_lookup_url_kwarg: URL kwarg name (default: lookup_url_kwarg or lookup_field)

    Example:
        # URL: /api/organizations/<int:pk>/member-tags/<int:tag_pk>
        class MemberTagAPI(GetParentObjectMixin, viewsets.ModelViewSet):
            parent_queryset = Organization.objects.all()
            parent_lookup_url_kwarg = 'pk'      # org ID from URL
            lookup_url_kwarg = 'tag_pk'         # tag ID from URL

            def get_queryset(self):
                return MemberTag.objects.filter(organization=self.parent_object)
    Nc                 ó"   — | j                  «       S ©N)Ú_get_parent_object©r
   s    r   Úparent_objectz"GetParentObjectMixin.parent_object+   s   € à×&Ñ&Ó(Ð(r   c                 ó6   — | j                   xs | j                  S r   )Úparent_lookup_fieldÚlookup_fieldr   s    r   Ú_get_parent_lookup_fieldz-GetParentObjectMixin._get_parent_lookup_field/   s   € Ø×'Ñ'Ò<¨4×+<Ñ+<Ð<r   c                 óR   — | j                   xs | j                  xs | j                  S r   )Úparent_lookup_url_kwargÚlookup_url_kwargr   r   s    r   Ú_get_parent_lookup_url_kwargz1GetParentObjectMixin._get_parent_lookup_url_kwarg2   s$   € Ø×+Ñ+ÒY¨t×/DÑ/DÒYÈ×HYÑHYÐYr   c                 óÄ  — | j                   €J d| j                  j                  z  «       ‚| j                   }t        |t        «      r|j                  «       }| j                  «       }|| j                  v s"J d| j                  j                  ›d|›d«       ‚| j                  «       }|| j                  |   i}t        |fi |¤Ž}| j                  | j                  |«       |S )z¨
        The same as get_object method from DRF, but for the parent object
        For example if you want to get project inside /api/projects/ID/tasks handler
        z3'%s' should include a `parent_queryset` attribute, zExpected view z1 to be called with a URL keyword argument named "zQ". Fix your URL conf, or set the `.lookup_field` attribute on the view correctly.)Úparent_querysetÚ	__class__r   Ú
isinstancer   Úallr    Úkwargsr   r   Úcheck_object_permissionsÚrequest)r
   Úquerysetr   r   Úfilter_kwargsÚobjs         r   r   z'GetParentObjectMixin._get_parent_object5   sá   € ð
 ×#Ñ#Ð/ð 	
ØAÀDÇNÁN×D[ÑD[Ñ[ó	
Ð/ð ×'Ñ'ˆÜh¤Ô)à—|‘|“~ˆHð  ×<Ñ<Ó>Ðà 4§;¡;Ñ.ñ 	
ð 37·.±.×2IÓ2IÒK[ð]ó	
Ð.ð ×4Ñ4Ó6ˆà% t§{¡{Ð3CÑ'DÐEˆÜ Ñ:¨MÑ:ˆð 	×%Ñ% d§l¡l°CÔ8àˆ
r   )r   r   r   Ú__doc__r"   r   r   r   r   r   r    r   r	   r   r   r   r      s<   „ ñð* €OØÐØ"Ðàñ)ó ð)ò=òZór   r   )r,   ÚloggingÚdjango.db.models.queryr   Údjango.utils.functionalr   Úrest_framework.genericsr   Ú	getLoggerr   Úloggerr   r   r	   r   r   ú<module>r3      s>   ðñã å +Ý 3Ý 5à	ˆ×	Ñ	˜8Ó	$€÷ñ ÷
Bò Br   