
    h
                     R    S SK r S SKJr  S SKJr  S SKJr  S SKJr   " S S\5      r	g)    N)settings)cached_property)FileSystemStorage)utilsc                      ^  \ rS rSrSrU 4S jr\S 5       r\S 5       r\	S 5       r
\	S 5       r\	S 5       rU 4S	 jrS
rU =r$ )TenantFileSystemStorage   zV
Implementation that extends core Django's FileSystemStorage for multi-tenant setups.
c                 v   > [         TU ]  " [        40 UD6  US:X  a  U R                  R	                  SS5        gg)z$Reset setting based property values.MULTITENANT_RELATIVE_MEDIA_ROOTrelative_media_rootN)super_clear_cached_propertiesr   __dict__pop)selfsettingkwargs	__class__s      N/var/www/html/env/lib/python3.13/site-packages/django_tenants/files/storage.pyr   0TenantFileSystemStorage._clear_cached_properties   s8    (<V<77MM3T: 8    c                      [         R                  R                  [        R                  [        R
                  5      $ ! [         a    [        R                  s $ f = fN)ospathjoinr   
MEDIA_ROOTr   AttributeErrorr   s    r   r   +TenantFileSystemStorage.relative_media_root   sC    	'77<< 3 3X5]5]^^ 	'&&&	's   ;> AAc                      [         R                  nSR                  S [         R                  U4 5       5      S-   nUR                  S5      (       d  SU-   nU$ ! [         a    Sn NVf = f)Nz%s/c              3   B   #    U  H  oR                  S 5      v   M     g7fr"   Nstrip.0ss     r   	<genexpr>=TenantFileSystemStorage.relative_media_url.<locals>.<genexpr>'   s     +qBpQGGCLLBp   )r   r   r   r   	MEDIA_URL
startswith)r   multitenant_relative_urls     r   relative_media_url*TenantFileSystemStorage.relative_media_url   sx    	,'/'O'O$ $'88+q8CUCUWoBp+q#qtw#w '22377'*-E'E$''  	, (,$	,s   A A)(A)c                 v    U R                  U R                  [        R                  " U R                  5      5      $ r   )_value_or_setting	_locationr   parse_tenant_config_pathr   r   s    r   base_location%TenantFileSystemStorage.base_location.   s+    %%dnne6T6TUYUmUm6noor   c                 T    [         R                  R                  U R                  5      $ r   )r   r   abspathr6   r   s    r   location TenantFileSystemStorage.location2   s    wwt1122r   c                     [         R                  " U R                  5      nU R                  c  U$ SSR	                  S U R                  U4 5       5      -   S-   nU$ )Nr"   c              3   B   #    U  H  oR                  S 5      v   M     g7fr$   r%   r'   s     r   r*   3TenantFileSystemStorage.base_url.<locals>.<genexpr>=   s     2uItA773<<Itr,   )r   r5   r0   	_base_urlr   )r   relative_tenant_media_urls     r   base_url TenantFileSystemStorage.base_url6   sY    $)$B$B4CZCZ$[!>>!,,$'#((2u$..ZsIt2u*u$ux{${!((r   c                 L   >  [         TU ]  U5      $ ! [         a    / / 4s $ f = f)z}
More forgiving wrapper for parent class implementation that does not insist on
each tenant having its own static files dir.
)r   listdirFileNotFoundError)r   r   r   s     r   rD   TenantFileSystemStorage.listdirA   s/    
	7?4((  	r6M	s    ## )__name__
__module____qualname____firstlineno____doc__r   r   r   r0   propertyr6   r:   rA   rD   __static_attributes____classcell__)r   s   @r   r   r      s}    ; ' ' ( ( p p 3 3 ) )	 	r   r   )
r   django.confr   django.utils.functionalr   django.core.files.storager   django_tenantsr   r   rG   r   r   <module>rT      s!    	   3 7  ?/ ?r   