Ñò
(·vLc           @   s±   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 „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d S(   iÿÿÿÿN(   t   call_command(   t   User(   t   ugettext(   t   Language(   t   Projectc         C   s+   d h t  d ƒ d 6t  d |  ƒ d 6} | S(   Ns  
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html  PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <title>%(title)s</title>
    <meta content="text/html; charset=utf-8" http-equiv="content-type" />
    <style type="text/css">
    body
    {
        background-color: #ffffff;
        color: #000000;
        font-family: Georgia, serif;
        margin: 40px auto;
        width: 740px;
    }
    h1
    {
        font-size: 185%%;
    }
    ul
    {
        list-style-type: square;
    }
    .error
    {
        background-color: inherit;
        color: #d54e21;
        font-weight: bold;
    }
    </style>
    </head>
    <body>
    <h1>%(title)s</h1>
    <p class="error">%(msg)s</p>
    s   Pootle: Installt   titles\   Error: "%s" while attempting to access the Pootle database, will try to initialize database.t   msg(   t   _(   t	   exceptiont   text(    (    s0   /var/www/Pootle/local_apps/pootle_misc/dbinit.pyt   header    s    $c          C   s$   d t  d ƒ }  t d d t ƒ|  S(   Nu   
    <p>%s</p>
    s   Creating database tables...t   syncdbt   interactive(   R   R    t   False(   R	   (    (    s0   /var/www/Pootle/local_apps/pootle_misc/dbinit.pyR   H   s    c          C   s   d t  d ƒ }  t d ƒ |  S(   Nu   
    <p>%s</p>
    s3   Creating default languages, projects and admin usert   initdb(   R   R    (   R	   (    (    s0   /var/www/Pootle/local_apps/pootle_misc/dbinit.pyR   O   s    
c          C   s   d t  d ƒ }  |  S(   Nu   
    <p>%s</p>
    <ul>
    s@   Calculating translation statistics, this will take a few minutes(   R   (   R	   (    (    s0   /var/www/Pootle/local_apps/pootle_misc/dbinit.pyt   stats_startV   s    c         C   s1   d t  d h |  i ƒ  d 6|  i ƒ  d 6ƒ } | S(   Nu   
    <li>%s</li>
    s&   %(language)s is %(percent)d%% completet   languaget   percent(   R   t	   localnamet   translated_percentage(   R   R	   (    (    s0   /var/www/Pootle/local_apps/pootle_misc/dbinit.pyt   stats_language]   s    	$c         C   s.   d t  d h |  i d 6|  i ƒ  d 6ƒ } | S(   Nu   
    <li>%s</li>
    s-   Project %(project)s is %(percent)d%% completet   projectR   (   R   t   fullnameR   (   R   R	   (    (    s0   /var/www/Pootle/local_apps/pootle_misc/dbinit.pyt   stats_projectd   s    	!c          C   s   d t  d ƒ }  |  S(   Nu   
    </ul>
    <p>%s</p>
    s>   Done calculating statistics for default languages and projects(   R   (   R	   (    (    s0   /var/www/Pootle/local_apps/pootle_misc/dbinit.pyt	   stats_endk   s    c          C   s   d h t  d ƒ d 6}  |  S(   Nsu   
    <p>%(endmsg)s</p>
    <div><script>setTimeout("location.reload()", 10000)</script></div>
    </body></html>
    sL   Initialized database, you will be redirected to the front page in 10 secondst   endmsg(   R   (   R	   (    (    s0   /var/www/Pootle/local_apps/pootle_misc/dbinit.pyt   footerr   s    c         c   s¿   t  i } t  i t  _ t |  ƒ Vt ƒ  Vt i i ƒ  i ƒ  d j o t	 ƒ  Vn t
 ƒ  Vx" t i i ƒ  D] } t | ƒ Vqh Wx" t i i ƒ  D] } t | ƒ Vq Wt ƒ  Vt ƒ  V| t  _ d S(   sR   Initialize the pootle database while displaying progress
    reports for each stepi    N(   t   syst   stdoutt   stderrR
   R   R   t   objectst   hide_defaultst   countR   R   R   t   iteratorR   R   R   R   R   (   R   R   R   R   (    (    s0   /var/www/Pootle/local_apps/pootle_misc/dbinit.pyt   staggered_installz   s"    	  	(   R   t   django.core.managementR    t   django.contrib.auth.modelsR   t   pootle.i18n.gettextR   R   t   pootle_language.modelsR   t   pootle_project.modelsR   R
   R   R   R   R   R   R   R   R"   (    (    (    s0   /var/www/Pootle/local_apps/pootle_misc/dbinit.pyt   <module>   s   	(							