3
(h$                 @   sr   d dl Z d dlZd dlmZ yd dlmZmZ W n$ ek
rT   d dlmZmZ Y nX d dl	m
Z
mZ dd ZdS )    N)staticfiles_storage)reverseNoReverseMatch)HttpResponseHttpResponseForbiddenc             C   s   | j jo| j jstdS i }d
}x6|D ].}ytd| ||< W q& tk
rR   Y q&X q&W tjdtj	t
jdtj	|f }t|j dd	S )zF
    Dynamic javascript serve defining the grappelli lookup urls.
    z"Permission denied"relatedm2mautocompletezgrp_%s_lookupz
        var DJNesting = (typeof window.DJNesting != "undefined")
                       ? DJNesting : {};
        DJNesting.adminStaticPrefix = %s;
        DJNesting.LOOKUP_URLS = %s;zadmin/zapplication/javascript)content_type)r   r   r	   )userZ	is_activeZis_staffr   r   r   textwrapdedentjsondumpsr   urlr   strip)requestZgrappelli_lookup_urlsZgrappelli_lookup_keyskserver_data_js r   C/tmp/pip-install-q3hcpn_q/django-nested-admin/nested_admin/views.pyr      s    

r   )r   r   Z"django.contrib.staticfiles.storager   Zdjango.urlsr   r   ImportErrorZdjango.core.urlresolversZdjango.httpr   r   r   r   r   r   r   <module>   s   