Ñò
Á£vLc           @   s|   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
 e i d „  ƒ Z d e
 f d „  ƒ  YZ d	 S(
   iÿÿÿÿ(   t   ugettext(   t   util(   t   User(   t   forms(   t   BaseModelFormSetc         C   sj   h  } t  d ƒ | d <d | d <d | d <t i |  d t | d d d t d t i i ƒ  i d	 ƒ d t ƒS(   Nt   Userst   titlet   changeuserst
   submitnamet   userst   formids   admin/admin_general_users.htmlt   fieldst   usernamet
   first_namet	   last_namet   emailt	   is_activet   is_superusert   formsett   querysett
   can_delete(   s   usernames
   first_names	   last_names   emails	   is_actives   is_superuser(	   t   _R   t   editR   t   BaseUserFormSett   objectst   hide_defaultst   order_byt   True(   t   requestt
   model_args(    (    s?   /var/www/Pootle/local_apps/pootle_app/views/admin/adminusers.pyt   view   s    

R   c           B   sD   e  Z d  Z d „  Z d „  Z e d „ Z e d „ Z e d „ Z RS(   s½  This formset deals with user admininistration. We have to add a
    password field so that the passwords of users can be set.

    We override the save_existing and save_new formset methods so that
    we can 1) yank out the password field before the formset attempts
    to save the field 'set_password' (which would fail anyway, since
    the User model has no such field) and 2) set the password for an
    object once it has been saved.
    c         C   sN   t  t |  ƒ i | | ƒ t i d t d t d ƒ d t i ƒ  ƒ | i d <d  S(   Nt   requiredt   labelt   Passwordt   widgett   set_password(	   t   superR   t
   add_fieldsR   t	   CharFieldt   FalseR   t   PasswordInputR   (   t   selft   formt   index(    (    s?   /var/www/Pootle/local_apps/pootle_app/views/admin/adminusers.pyR%   2   s    c         C   s   | d i  } | i d =| S(   NR#   (   t   dataR   (   R)   R*   t   password(    (    s?   /var/www/Pootle/local_apps/pootle_app/views/admin/adminusers.pyt	   del_field6   s    
c         C   ss   t  } | d j o | i | ƒ t } n | i | i j o | i | _ t } n | o | o | i ƒ  n | S(   sA   process fields that require behavior different from model defaultt    (   R'   R#   R   t   is_staffR   t   save(   R)   t   instanceR-   t   committ   changed(    (    s?   /var/www/Pootle/local_apps/pootle_app/views/admin/adminusers.pyt
   save_extra;   s    

c         C   s:   |  i  | ƒ } |  i t t |  ƒ i | | | ƒ | | ƒ S(   N(   R.   R5   R$   R   t   save_existing(   R)   R*   R2   R3   R-   (    (    s?   /var/www/Pootle/local_apps/pootle_app/views/admin/adminusers.pyR6   N   s    c         C   s7   |  i  | ƒ } |  i t t |  ƒ i | | ƒ | | ƒ S(   N(   R.   R5   R$   R   t   save_new(   R)   R*   R3   R-   (    (    s?   /var/www/Pootle/local_apps/pootle_app/views/admin/adminusers.pyR7   R   s    (	   t   __name__t
   __module__t   __doc__R%   R.   R   R5   R6   R7   (    (    (    s?   /var/www/Pootle/local_apps/pootle_app/views/admin/adminusers.pyR   '   s   			N(   t   django.utils.translationR    R   t   pootle_app.views.adminR   t   django.contrib.auth.modelsR   t   djangoR   t   django.forms.modelsR   t   user_is_adminR   R   (    (    (    s?   /var/www/Pootle/local_apps/pootle_app/views/admin/adminusers.pyt   <module>   s   
