
    j.                        d Z ddlmZ ddlmZmZmZ ddlmZ ddl	m
Z
mZ ddlmZ  edd	g
      ZdddZddZej#                  d       ee      fdd       Zej#                  d       ee      fdd       Zy)z;Guidance documents (PDFs), visible to signed-in users only.    )annotations)	APIRouterDependsHTTPException)FileResponse   )Usercurrent_user)get_settingsz	/guidanceguidance)prefixtagsz#USDA FS Avalanche Forecast Guidanceu.   Sierra Avalanche Center — Avalanche Problems)zforecast-guidance.pdfzsac-avalanche-problems.pdfc                    t               j                  } | j                         si S t        | j	                  d            D ci c]{  }|j
                  |j
                  t        j                  |j
                  |j                  j                  dd      j                               |j                         j                  d} c}S c c}w )Nz*.pdf- )nametitlebytes)r   guidance_docs_diris_dirsortedglobr   TITLESgetstemreplacer   statst_size)rootps     1/var/www/avy-guidance/api/app/routers/guidance.py_docsr"      s    >++D;;=	 		'*+ 	
&**QVVQVV^^CQT=U=[=[=]*^ijioioiqiyiyzz  s   B Cz/docsc                D    t        t               j                               S )N)listr"   values)users    r!   	list_docsr'      s     !!    z/docs/{name}c                ~    t               }| |vrt        dd      t        t               j                  | z  d| d      S )Ni  zDocument not foundzapplication/pdfinline)
media_typefilenamecontent_disposition_type)r"   r   r   r   r   )r   r&   docss      r!   get_docr/   "   sD    7D4C!566884?L]hl19; ;r(   N)returnzdict[str, dict])r&   r	   )r   strr&   r	   )__doc__
__future__r   fastapir   r   r   fastapi.responsesr   authr	   r
   settingsr   routerr   r"   r   r'   r/    r(   r!   <module>r:      s    A " 5 5 * % #	+ZL	9 C"R
 G"<0 " " N$+L$9 ; ;r(   