mò
Á2ÇEc           @   sv  d  k  l Z l Z l Z d k l Z d k Td k l Z l	 Z	 d k
 l Z d k l Z d k l Z l Z d k l Z d k l Z d k Td	 k l Z h  d
 d <d d <d d <Z d „  Z d „  Z d  d „ Z d „  Z d „  Z d „  Z d „  Z  d e! f d „  ƒ  YZ" d „  Z# d „  Z$ d e! f d „  ƒ  YZ% d „  Z& e e& ƒ Z& d  d „ Z' d „  Z( e e( ƒ Z( d  S(!   (   s   HttpResponses   Http404s   HttpResponseRedirect(   s   render_to_response(   t   *(   s   RequestContexts   Context(   s   User(   s   login_required(   s   Logs   UserProfile(   s   bad_or_missing(   s   wikiwhat(   s
   render_thmt   wikis   Wiki: t   bibs   Bibliography: t   users   User: c         C   sÃ   |  i d ƒ } d } } t | ƒ d j o3 t i | d ƒ o t t | d ƒ } | d =n t | ƒ d j o( | d d j o t d ƒ } | d =n t	 | d ƒ | d <| d i
 | ƒ | S(   Nt   /t    i   i    iÿÿÿÿt   talks    discussion(   t   titlet   splitt   ltitlet   prefixt   suffixt   lent
   titleprefst   has_keyt   _t   i18n_baselangt   join(   R   R   R	   R
   (    (    t3   /home/raph/garden/ghestalt/../ghestalt/app/views.pyt	   wikititle   s    
'$c         C   s   t  t |  ƒ d t |  ƒ ƒ S(   Ns   /wiki/HomePage(   t   HttpResponseRedirectt   i18n_site_baset   requestt   i18n_wiki_suffix(   R   (    (    R   t   wiki_homepage   s    c   	         s=  t  | ƒ ‰  y t i i d ˆ  ƒ i ƒ  } Wnv t ˆ  ƒ ˆ  j o t	 |  t | ƒ d ˆ  ƒSn | o
 | ‰  n t d h  d t ˆ  ƒ <d ˆ  <t |  ƒ ƒ Sn Xt ˆ  ƒ d t i j o
 t } n t } t d „  t i i d t ˆ  ƒ ƒ i d ƒ i ƒ  ƒ } t ‡  d †  | ƒ } | i ƒ  d  } ˆ  } t ˆ  ƒ | j o t ˆ  ƒ } n yE t ˆ  ƒ d	 |  i d
 | j o t ˆ  ƒ d	 |  i d
 } n Wn t j
 o n X| o | } | ‰  n t d h  d t | ƒ <d | <d | <d ˆ  <d | <d | <d | <d | i i  d ƒ <d | <t |  ƒ ƒ S(   Nt   whatt   origwhats   missing.htmlR   i   c         C   s   |  d S(   NR   (   t   x(   R   (    (    R   t   <lambda>-   s    t   what__startswithc            s    |  i d d ƒ d t ˆ  ƒ j S(   NR   i   i    (   R   t   rsplitR   R   (   R   (   R   (    R   R   .   s    R   t	   otro_langs	   wiki.htmlt   logt	   all_langst   trans_targett   trans_sourcet   no_titles   ==t   CONTENT_BIDI(!   t   wikiwhatt   pageR   t   Logt   objectst   filtert   latestR    R   t   wiki_showpageR   R   t   render_to_responseR   t   RequestContextt   i18n_lang_suffixt   settingst   LANGUAGES_BIDIt   Truet   content_bidit   Falset   mapt   valuest   distinctR!   t   sortt   NoneR"   R#   t   sessiont   KeyErrort   ldatat
   startswith(	   R   R'   R   R!   R   R    R3   R"   R#   (    (   R   R   R,      s<    
!
6
"#
lc         C   sy   y t  i i d | ƒ } Wn  t  i j
 o t d ƒ Sn Xt d h  d t | i	 ƒ <d | <d | i	 <t
 |  ƒ ƒ S(   Nt   ids   Page does not exists	   wiki.htmlR   R    R   (   R(   R)   t   gett   idnumR    t   DoesNotExistt   HttpResponseR-   R   R   R.   R   (   R   R@   R    (    (    R   t   wiki_showid?   s    0c         C   sC   t  i i d d ƒ i ƒ  i d ƒ } t d h  d | <t |  ƒ ƒ S(   NR   s   wiki/R   s
   index.htmlR    (	   R(   R)   R*   R7   R6   R    R-   R.   R   (   R   R    (    (    R   t
   wiki_indexG   s    $c         C   s\   t  | ƒ } t i i d | ƒ i d ƒ d  } t d h  d t	 | ƒ <d | <t
 |  ƒ ƒ S(   NR   s   -idi   s   history.htmlR   R    (   R&   R'   R   R(   R)   R*   t   order_byR    R-   R   R.   R   (   R   R'   R   R    (    (    R   t   wiki_showhistoryL   s    "!c         C   s;   t  i i ƒ  i d ƒ d  } t d h  d | <t |  ƒ ƒ S(   Ns   -idi2   s   recent.htmlR    (   R(   R)   t   allRE   R    R-   R.   R   (   R   R    (    (    R   t   wiki_recentR   s    t   NewPageFormc           B   sP   t  Z e d e d ƒ d d d e ƒ Z e d e d ƒ d e i ƒ Z	 d „  Z
 RS(	   Nt   labels	   Page namet
   max_lengthi   t   requiredt   Languaget   choicesc         C   s   |  i S(   N(   t   selft
   clean_data(   RO   (    (    R   t   cleanZ   s    (   t   __name__t
   __module__t	   CharFieldR   R4   t	   page_namet   ChoiceFieldR0   t	   LANGUAGESt   languageRQ   (    (    (    R   RI   W   s   !c         C   sÑ   |  i oŒ t |  i ƒ } | i ƒ  ol | i i d ƒ } | i i d ƒ } | t	 i
 d  j o d | } n d } t t |  ƒ d | | ƒ Sq² n t h  d |  i
 d  <ƒ } t d h  d | <t |  ƒ ƒ S(	   NRU   RX   i   R   R   s   /edit/wiki/s   newpage.htmlt   form(   R   t   POSTRI   RY   t   is_validRP   R?   RU   RX   R0   t   LANGUAGE_CODER   R   R   R-   R.   (   R   RY   RX   RU   R   (    (    R   t   wiki_new]   s    
$c         C   s;   t  i i ƒ  i d ƒ d  } t d h  d | <t |  ƒ ƒ S(   Nt   create_datei2   s   roster.htmlt   userlist(   t   UserProfileR)   RG   RE   R_   R-   R.   R   (   R   R_   (    (    R   t   wiki_rosterm   s    t   LogFormc           B   sG   t  Z e d e d h  d d <d d <ƒ d e d ƒ ƒ Z d	 „  Z RS(
   Nt   widgett   attrst   rowsi   t   colsiP   RJ   t   Textc         C   s   |  i S(   N(   RO   RP   (   RO   (    (    R   RQ   t   s    (   RR   RS   RT   t   TextareaR   R<   RQ   (    (    (    R   Rb   r   s   6c   
      C   s‚  t  | ƒ } |  i oTt |  i ƒ } | i ƒ  o4y t i	 i
 d |  i i ƒ }	 Wn t |  d ƒ Sn Xd |  i j o• t | ƒ d t i j o
 t } n t } t d h  d | <d t | ƒ <d d	 <d
 d <d | i i
 d ƒ <d | <d | <t |  ƒ ƒ Sn t d | d | i i
 d ƒ i d ƒ d
 |	 i ƒ } | i ƒ  t t |  ƒ d | ƒ Sq9nÐ |  i i  d ƒ o |  i d } t } n | } t } y† t i	 i# d | ƒ i$ ƒ  } d t% d ƒ d } | o4 t h  d | | i' i( d d ƒ | d <ƒ } n t h  d | i' <ƒ } Wn t ƒ  } n Xt d h  d | <d t | ƒ <d d	 <d
 d <d | <t |  ƒ ƒ S(   NR>   sC   Seems you are not logged in properly. Perhaps, you should re-login.t   _previewi   s	   edit.htmlRY   R   t   mtimet   nowt   musert   met   previewR<   R   R%   s   utf-8R   t   sources   
^^^^^ s+   Replace caret marked lines with translations   
^ s   
()   R&   R'   R   R   RZ   Rb   RY   R[   t   UserR)   R?   R   R>   t   bad_or_missingR/   R0   R1   R2   R3   R4   R-   R   RP   R.   R(   t   encodet   usernameR    t   saveR   R   t   GETR   Ro   t   add_prefixesR*   R+   R   t   trans_messageR<   t   replace(
   R   R'   Rw   R3   R   R    Rv   Ro   RY   R   (    (    R   t   wiki_editpagew   s@    

Z3
 
4<c         C   sŸ  | } y# t i i d | d ƒ i ƒ  } Wn) t i j
 o h  d | d <} n Xy5 t i i d | d ƒ i ƒ  } t	 | | | ƒ } Wn× t i j
 oÈ yJ t i i d | d ƒ i ƒ  } h  d t | ƒ <d | <d | <} Wqdt i j
 oe t | ƒ | j o t |  t | ƒ d | ƒSn t d	 h  d t | ƒ <d | <t |  ƒ ƒ SqdXn X| o
 | } n | | d <| | d <t d
 | t |  ƒ ƒ S(   NR   s   /_norms   /_thms   /_stmtR   t   normt   thmR   s   missing.htmls   theorem.html(   t   theoremR   R(   R)   R*   R+   Rz   RA   R{   t
   render_thmt   render_dictt   stmtR   R   t   show_theoremR   R-   R.   R   (   R   R|   R   R   R   R~   R{   Rz   (    (    R   R€   Ÿ   s0    #+!


c         C   sk   t  i i d |  i i ƒ } t i i d | i ƒ i	 d ƒ d  } t d h  d | i <d | <t |  ƒ ƒ S(   NR>   Rl   s   -idi   s   recent_activity.htmlt   theuserR    (   Rp   R)   R?   R   R   R>   R(   R*   Rs   RE   R    R-   R.   (   R   R    R   (    (    R   t   recent_actionsº   s    %N()   t   django.httpRB   t   Http404R   t   django.shortcutsR-   t   django.newformst   django.templateR.   t   Contextt   django.contrib.auth.modelsRp   t   django.contrib.auth.decoratorst   login_requiredt   ghestalt.app.modelsR(   R`   t   ghestalt.app.utilsRq   t   ghestalt.app.log_whatR&   t   ghestalt.i18n.utilst   ghestalt.app.showthmR}   R   R   R   R9   R,   RC   RD   RF   RH   t   FormRI   R]   Ra   Rb   Ry   R€   R‚   (   R&   R(   R.   Rb   R‚   R   RB   Ry   R`   RI   R‹   Rq   RD   Rp   R   R]   RH   R   Rˆ   R„   RC   R}   R   R,   Ra   R-   R€   RF   (    (    R   t   ?   s6   !		!							&	