Ñò
Ç*“Lc           @   sQ  d  d k  Z  d  d k l Z d  d k l Z d  d k l Z d  d k l	 Z	 d  d k
 l Z d  d k l Z d  d k l Z d  d	 k l Z d  d
 k l Z d  d k l Z d  d k l Z d  d k l Z l Z d  d k l Z d  d k l Z d  d k l  Z  d „  Z! d „  Z" d „  Z# d „  Z$ d „  Z% e d „  ƒ Z& e d „  ƒ Z' d S(   iÿÿÿÿN(   t   HttpResponse(   t   ugettext(   t   render_to_response(   t   RequestContext(   t   cache(   t
   simplejson(   t   User(   t   depcheck(   t   user_is_admin(   t
   sum_column(   t
   Suggestion(   t   UnitR
   (   t   PootleProfile(   t
   TRANSLATED(   t
   Submissionc          C   s„  g  }  t  i ƒ  \ } } | o t d | ƒ } d } n$ t d h | d 6d d 6ƒ } d } |  i h d d	 6| d
 6| d 6ƒ t  i ƒ  \ } } | o t d | ƒ } d } n t d | ƒ } d } |  i h d d	 6| d
 6| d 6ƒ t  i ƒ  \ } } | o t d | ƒ } d } nG | d  j	 o' t d h | d 6d d 6ƒ } d } n t d ƒ } d } |  i h d d	 6| d
 6| d 6ƒ |  S(   Ns'   Translate Toolkit version %s installed.t   goodsX   Translate Toolkit version %(installed)s installed. Pootle requires version %(required)s.t	   installeds   1.8.0t   requiredt   errort	   translatet
   dependencyt   statet   texts   Django version %s is installed.sK   Django version %s is installed, but a higher version is highly recommended.t   djangos   lxml version %s is installed.se   lxml version %(installed)s is installed. Pootle requires version %(required)s for XML format support.s   2.1.4sC   lxml is not installed. Pootle requires lxml for XML format support.t   lxml(   R   t   test_translatet   _t   appendt   test_djangot	   test_lxmlt   None(   R   t   statust   versionR   R   (    (    s>   /var/www/Pootle/local_apps/pootle_app/views/admin/dashboard.pyt   required_depcheck+   s4    
"
"

"c          C   s  g  }  t  i ƒ  p% |  i h d d 6t d ƒ d 6ƒ n t  i ƒ  p% |  i h d d 6t d ƒ d 6ƒ n t  i ƒ  p% |  i h d d 6t d ƒ d 6ƒ n t  i ƒ  p% |  i h d	 d 6t d
 ƒ d 6ƒ n t  i ƒ  p% |  i h d d 6t d ƒ d 6ƒ n |  S(   Nt   unzipR   sS   Can't find the unzip command. Uploading archives is faster if "unzip" is available.R   s	   iso-codessT   Can't find the ISO codes package. Pootle uses ISO codes to translate language names.t   gaupols\   Can't find the aeidon package. Pootle requires Gaupol or aeidon to support subtitle formats.t   levenshteinsa   Can't find python-levenshtein package. Updating from templates is faster with python-levenshtein.t   indexersl   No text indexing engine found. Searching is faster if an indexing engine like Xapian or Lucene is installed.(   R   t
   test_unzipR   R   t   test_iso_codest   test_gaupolt   test_levenshteint   test_indexer(   t   optional(    (    s>   /var/www/Pootle/local_apps/pootle_app/views/admin/dashboard.pyt   optional_depcheckN   s"    c          C   sD  g  }  t  i ƒ  pH t  i ƒ  o t d ƒ } n t d ƒ } |  i h d d 6| d 6ƒ n t  i ƒ  o½ t  i ƒ  o‹ t  i ƒ  p% |  i h d d 6t d ƒ d 6ƒ q!t  i ƒ  pH t  i	 ƒ  o t d ƒ } n t d	 ƒ } |  i h d
 d 6| d 6ƒ q!qF|  i h d d 6t d ƒ d 6ƒ n" |  i h d d 6t d ƒ d 6ƒ t  i
 ƒ  p% |  i h d d 6t d ƒ d 6ƒ n t  i ƒ  p% |  i h d d 6t d ƒ d 6ƒ n t  i ƒ  p% |  i h d d 6t d ƒ d 6ƒ n t  i ƒ  p% |  i h d d 6t d ƒ d 6ƒ n t  i ƒ  p% |  i h d d 6t d ƒ d 6ƒ n |  S(   Ns³   Using the default sqlite3 database engine. SQLite is only suitable for small installations with a small number of users. Pootle will perform better with the MySQL database engine.sá   Using the default sqlite3 database engine. SQLite is only suitable for small installations with a small number of users. Pootle will perform better with the MySQL database engine, but you need to install python-MySQLdb first.t   dbR   R   R   s…   Pootle is configured to use memcached as a caching backend, but can't connect to the memcached server. Caching is currently disabled.s^   For optimal performance, use django.contrib.sessions.backends.cached_db as the session engine.sZ   For optimal performance, use django.contrib.sessions.backends.cache as the session engine.t   sessions‹   Pootle is configured to use memcached as caching backend, but Python support for memcached is not installed. Caching is currently disabled.s>   For optimal performance, use memcached as the caching backend.t	   webservers5   For optimal performance, use Apache as the webserver.t
   from_emailsk   The "from" address used to send registration emails is not specified. Also review the mail server settings.t   contact_emailsh   No contact address is specified. The contact form will allow users to contact the server administrators.t   debugsy   Running in debug mode. Debug mode is only needed when developing Pootle. For optimal performance, disable debugging mode.t   livetranslations’   Running in live translation mode. Live translation is useful as a tool to learn about Pootle and localization, but has high impact on performance.(   R   t   test_dbt   test_mysqldbR   R   t
   test_cachet   test_memcachet   test_memcachedt   test_sessiont   test_cached_db_sessiont   test_webservert   test_from_emailt   test_contact_emailt
   test_debugt   test_livetranslation(   t   optimalR   (    (    s>   /var/www/Pootle/local_apps/pootle_app/views/admin/dashboard.pyt   optimal_depcheckh   sH    #c         C   s8   x1 |  i  ƒ  D]# } t i d |  | d ƒ |  | <q Wd  S(   Ns   %di   (   t   keyst   localet   format(   t   dictt   k(    (    s>   /var/www/Pootle/local_apps/pootle_app/views/admin/dashboard.pyt   _format_numbersš   s     c          C   s¦   t  i d ƒ }  |  d  j o† h  }  t t i i d t ƒ i ƒ  d d ƒ |  d <t	 i i ƒ  t
 i i ƒ  |  d <t i i ƒ  |  d <t |  ƒ t  i d |  d ƒ n |  S(	   Nt   server_statst	   is_activei   i    t
   user_countt   submission_countt   pending_counti€Q (   R   t   getR   t   maxR   t   objectst   filtert   Truet   countR   t   SuggestiontStatR
   RG   t   set(   t   result(    (    s>   /var/www/Pootle/local_apps/pootle_app/views/admin/dashboard.pyRH   ž   s    , 
c         C   s  t  i d ƒ } | d  j o:h  } t i i d t ƒ i d d! ƒ i d d ƒ i ƒ  } | i	 d	 ƒ i
 ƒ  i ƒ  | d
 <| i	 d ƒ i
 ƒ  i ƒ  | d <| i	 d ƒ i
 ƒ  i ƒ  | d <t | d" d t ƒ} | d | d <| d p d | d <t i i d d  ƒ t i i d d  ƒ Bt i i d d  ƒ Bi ƒ  i ƒ  | d <t | ƒ t  i d | d ƒ n h t d ƒ d
 6t d ƒ d 6t d ƒ d 6t d ƒ d 6t d ƒ d 6t d ƒ d 6} g  } x/ | i ƒ  D]! } | i | | | | f ƒ q½Wt i | ƒ } t | d d  ƒS(#   Nt   server_stats_moret
   state__gtet-   store__translation_project__project__code__int   pootlet   tutorialt   terminologyt*   store__translation_project__language__codet	   templatest   storet   store_countt#   store__translation_project__projectt   project_countt$   store__translation_project__languaget   language_countt   source_wordcountRR   t   string_counti    t
   word_countt
   submissiont
   suggestiont	   suggestert   user_active_counti€Q t   Filess   Active projectss   Active languagess   Translated stringss   Translated wordss   Active userst   mimetypes   application/json(   s   pootles   tutorials   terminology(   s   source_wordcount(   R   RM   R   R   RO   RP   R   t   excludet   order_byt   valuest   distinctRR   R	   RQ   R   RG   RT   R   RB   R   R   t   dumpsR    (   t   requestRU   t
   unit_queryt   sumst   stat_stringst   responseRF   (    (    s>   /var/www/Pootle/local_apps/pootle_app/views/admin/dashboard.pyRV   «   s8    %&
 c         C   sG   h t  ƒ  d 6t ƒ  d 6t ƒ  d 6t ƒ  d 6} t d | d t |  ƒ ƒS(   NRH   R   R+   R@   s   admin/dashboard.htmlt   context_instance(   RH   R!   R,   RA   R   R   (   Rr   t   template_vars(    (    s>   /var/www/Pootle/local_apps/pootle_app/views/admin/dashboard.pyt   viewÊ   s    


((   RC   t   django.httpR    t   django.utils.translationR   R   t   django.shortcutsR   t   django.templateR   t   django.core.cacheR   t   django.utilsR   t   django.contrib.auth.modelsR   RY   R   t   pootle_app.views.admin.utilR   t   pootle_misc.aggregateR	   t   pootle_app.modelsR
   RS   t   pootle_store.modelsR   t   pootle_profile.modelsR   t   pootle_store.utilR   t   pootle_statistics.modelsR   R!   R,   RA   RG   RH   RV   Ry   (    (    (    s>   /var/www/Pootle/local_apps/pootle_app/views/admin/dashboard.pyt   <module>   s,   	#		2		