
    =!g                         d dl Z d dlmZmZ 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 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mZ ej        ZeefeefeeefdZd Z	 	 ddZdS )    N)WRAPPER_ASSIGNMENTSwrapsadd_never_cache_headers)
cache_page)vary_on_headers)
exceptions)Response)api_settings)APIView   )swagger_settings)ReDocOldRendererReDocRendererSwaggerJSONRendererSwaggerUIRendererSwaggerYAMLRenderer_SpecRenderer)swaggerredocz	redoc-oldc                 J     t           t                     fd            }|S )zX
    Decorator that adds headers to a response so that it will
    never be cached.
    )assignedc                 P     | g|R i |}d }|                     |           |S )Nc                 $    t          |            | S Nr   )responses    I/var/www/html/nourish/venv/lib/python3.11/site-packages/drf_yasg/views.pycallbackzBdeferred_never_cache.<locals>._wrapped_view_func.<locals>.callback,   s    #H---O    )add_post_render_callback)requestargskwargsr   r   	view_funcs        r   _wrapped_view_funcz0deferred_never_cache.<locals>._wrapped_view_func$   sL    9W6t666v66	 	 	 	))(333r   )r   r   )r$   r%   s   ` r   deferred_never_cacher&      s?     92333    43 r   Fc	                    
 ||pt           j        |

t          j        
|t          j         pt           j         pg t          fdt          D                       t           j        r6t          j
        dt                     t          d D                       z   G 
 f	ddt                    }	|	S )a  Create a SchemaView class with default renderers and generators.

    :param Info info: information about the API; if omitted, defaults to :ref:`DEFAULT_INFO <default-swagger-settings>`
    :param str url: same as :class:`.OpenAPISchemaGenerator`
    :param patterns: same as :class:`.OpenAPISchemaGenerator`
    :param urlconf: same as :class:`.OpenAPISchemaGenerator`
    :param bool public: if False, includes only the endpoints that are accessible by the user viewing the schema
    :param list validators: a list of validator names to apply; the only allowed value is ``ssv``, for now
    :param type generator_class: schema generator class to use; should be a subclass of :class:`.OpenAPISchemaGenerator`
    :param list authentication_classes: authentication classes for the schema view itself
    :param list permission_classes: permission classes for the schema view itself
    :return: SchemaView class
    :rtype: type[drf_yasg.views.SchemaView]
    Nc              3   B   K   | ]}|                               V  d S r   )with_validators).0renderer
validatorss     r   	<genexpr>z"get_schema_view.<locals>.<genexpr>P   s1      ``XH44Z@@``````r   a  SwaggerJSONRenderer & SwaggerYAMLRenderer's `format` has changed to not include a `.` prefix, please silence this warning by setting `SWAGGER_USE_COMPAT_RENDERERS = False` in your Django settings and ensure your application works (check your URLCONF and swagger/redoc URLs).c              3      K   | ]A}t          |t          t          f          t          |j        |fd d|j        z   i          V  BdS )format.N)
issubclassr   r   type__name__r/   )r*   clss     r   r-   z"get_schema_view.<locals>.<genexpr>Z   si       !
 !
# 35HIJJ!
v#
2B'CDD!
 !
 !
 !
 !
 !
r   c                      	 e Zd ZdZdZZZ ZZZ	dfd	Z
ed             Zedd            Zedfd	            Zedfd
	            ZdS )#get_schema_view.<locals>.SchemaViewTN c                 2   |j         p|pd}t          |j        t                    r|                     |	          }n|                     |g           }|                    || j                  }|t          j                    t          |          S )Nr7   )patterns)
version
isinstanceaccepted_rendererr   generator_class
get_schemapublicr	   PermissionDeniedr
   )
selfr!   r:   r/   	generatorschemainfor9   urlurlconfs
         r   getz'get_schema_view.<locals>.SchemaView.geti   s    o66BG'3]CC R 00wXwWW		 00wb0QQ	))'4;??F~ 1333F###r   c                      t          dd          |          } t          |fi ||          }t          |          }|S )zOverride this method to customize how caching is applied to the view.

            Arguments described in :meth:`.as_cached_view`.
            CookieAuthorization)r   r   r&   )r4   viewcache_timeoutcache_kwargss       r   apply_cachez/get_schema_view.<locals>.SchemaView.apply_cacheu   sN     >?8_==dCCD<:m<<|<<TBBD'--DKr   r   c                     |pi } | j         di |}|dk    r|                     |||          }n|rt          j        d           |S )a  
            Calls .as_view() and wraps the result in a cache_page decorator.
            See https://docs.djangoproject.com/en/dev/topics/cache/

            :param int cache_timeout: same as cache_page; set to 0 for no cache
            :param dict cache_kwargs: dictionary of kwargs to be passed to cache_page
            :param initkwargs: kwargs for .as_view()
            :return: a view instance
            r   z:cache_kwargs ignored because cache_timeout is 0 (disabled) )as_viewrN   warningswarn)r4   rL   rM   
initkwargsrK   s        r   as_cached_viewz2get_schema_view.<locals>.SchemaView.as_cached_view   sf     (-2L3;,,,,D!!t]LII \Z[[[Kr   c                 4    |                      ||          S )a  
            Instantiate this view with just JSON and YAML renderers, optionally wrapped with cache_page.
            See https://docs.djangoproject.com/en/dev/topics/cache/.

            :param int cache_timeout: same as cache_page; set to 0 for no cache
            :param dict cache_kwargs: dictionary of kwargs to be passed to cache_page
            :return: a view instance
            renderer_classes)rU   )r4   rL   rM   _spec_rendererss      r   
without_uiz.get_schema_view.<locals>.SchemaView.without_ui   s!     %%m\Tc%dddr   r   c                     |t           v s%J dd                    t                     z               t           |         z   }|                     |||          S )a  
            Instantiate this view with a Web UI renderer, optionally wrapped with cache_page.
            See https://docs.djangoproject.com/en/dev/topics/cache/.

            :param str renderer: UI renderer; allowed values are ``swagger``, ``redoc``
            :param int cache_timeout: same as cache_page; set to 0 for no cache
            :param dict cache_kwargs: dictionary of kwargs to be passed to cache_page
            :return: a view instance
            z supported default renderers are z, rW   )UI_RENDERERSjoinrU   )r4   r+   rL   rM   rX   rY   s        r   with_uiz+get_schema_view.<locals>.SchemaView.with_ui   s`     |+++-ORVR[R[\hRiRi-i++++H5G%%m\Td%eeer   )r7   N)r   N)r   r   N)r3   
__module____qualname___ignore_model_permissionsrC   r?   r=   authentication_classespermission_classesrX   rG   classmethodrN   rU   rZ   r^   )	_auth_classes_generator_class_perm_classes_publicrY   rD   r9   rE   rF   s	   r   
SchemaViewr6   `   s       $(!*!.**
	$ 
	$ 
	$ 
	$ 
	$ 
	$ 
	$ 
	$ 
	$ 
	 	 
	 
	 	 	 
	$ 
		e 		e 		e 		e 		e 
		e 
	f 	f 	f 	f 	f 
	f 	f 	fr   ri   )r   DEFAULT_GENERATOR_CLASSr   DEFAULT_AUTHENTICATION_CLASSESDEFAULT_PERMISSION_CLASSESDEFAULT_INFOtupleSPEC_RENDERERSUSE_COMPAT_RENDERERSrR   rS   DeprecationWarningr   )rD   rE   r9   rF   r?   r,   r=   rb   rc   ri   re   rf   rg   rh   rY   s   ```` `    @@@@@r   get_schema_viewrr   6   sk     G&R*:*R*M$C&M$?0#0D!rJ````Q_`````O , 
; 	  	  	  	5 !
 !
&!
 !
 !
 
 
 	
Mf Mf Mf Mf Mf Mf Mf Mf Mf Mf Mf Mf Mf Mf MfW Mf Mf Mf^ r   )	NNNNFNNNN) rR   	functoolsr   r   django.utils.cacher   django.views.decorators.cacher   django.views.decorators.varyr   rest_frameworkr	   rest_framework.responser
   rest_framework.settingsr   rest_framework.viewsr   app_settingsr   	renderersr   r   r   r   r   r   DEFAULT_SPEC_RENDERERSro   r\   r&   rr   rP   r   r   <module>r~      su    0 0 0 0 0 0 0 0 6 6 6 6 6 6 4 4 4 4 4 4 8 8 8 8 8 8 % % % % % % , , , , , , 0 0 0 0 0 0 ( ( ( ( ( ( * * * * * *                "8!=1./"M3DE   0 `dZ^y y y y y yr   