Ñò
T6Jc           @   s-   d  d k  l Z d e i f d     YZ d S(   i˙˙˙˙(   t   formst   SiteSettingsFormc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   sÒ   
    A base form for loading/saving settings for a SiteConfiguration. This is
    meant to be subclassed for different settings pages. Any fields defined
    by the form will be loaded/saved automatically.
    c         O   s?   t  i i |  | |  | |  _ h  |  _ h  |  _ |  i   d  S(   N(   R    t   Formt   __init__t
   siteconfigt   disabled_fieldst   disabled_reasonst   load(   t   selfR   t   argst   kwargs(    (    s9   /var/www/Pootle/external_apps/djblets/siteconfig/forms.pyR   #   s
    			c         C   sİ   t  |  d  o t |  i d g   } n xy |  i D]n } |  i i |  } t | t  p | o | |  i | _ n | |  i	 j o d |  i | i
 i d <q3 q3 Wd S(   s9  
        Loads settings from the ```SiteConfiguration''' into this form.
        The default values in the form will be the values in the settings.

        This also handles setting disabled fields based on the
        ```disabled_fields''' and ```disabled_reasons''' variables set on
        this form.
        t   Metat   save_blacklistt   disabledN(   t   hasattrt   getattrR   t   fieldsR   t   gett
   isinstancet   boolt   initialR   t   widgett   attrs(   R   R   t   fieldt   value(    (    s9   /var/www/Pootle/external_apps/djblets/siteconfig/forms.pyR   +   s    	
 c         C   s   |  i  p{ t |  d  o t |  i d g   } n x> |  i i   D]- \ } } | | j o | |  i i | <qC qC W|  i i   n d S(   sU   
        Saves settings from the form back into the ```SiteConfiguration'''.
        R   R   N(	   t   errorsR   R   R   t   cleaned_datat	   iteritemsR   t   settingst   save(   R   R   t   keyR   (    (    s9   /var/www/Pootle/external_apps/djblets/siteconfig/forms.pyR   @   s    
 (   t   __name__t
   __module__t   __doc__R   R   R   (    (    (    s9   /var/www/Pootle/external_apps/djblets/siteconfig/forms.pyR      s   		N(   t   djangoR    R   R   (    (    (    s9   /var/www/Pootle/external_apps/djblets/siteconfig/forms.pyt   <module>   s   