Ñò
¤.Jc           @   sž   d  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 d
 „ Z d e d d d „ Z d S(   s;   
Views which allow users to create and activate accounts.

iÿÿÿÿ(   t   settings(   t   reverse(   t   HttpResponseRedirect(   t   render_to_response(   t   RequestContext(   t   RegistrationForm(   t   RegistrationProfiles   registration/activate.htmlc         C   s£   | i  ƒ  } t i i | ƒ } | d j o
 h  } n t |  ƒ } x; | i ƒ  D]- \ } } t | ƒ o
 | ƒ  p | | | <qN Wt | h | d 6t	 i
 d 6d | ƒS(   sÛ  
    Activate a ``User``'s account from an activation key, if their key
    is valid and hasn't expired.
    
    By default, use the template ``registration/activate.html``; to
    change this, pass the name of a template as the keyword argument
    ``template_name``.
    
    **Required arguments**
    
    ``activation_key``
       The activation key to validate and use for activating the
       ``User``.
    
    **Optional arguments**
       
    ``extra_context``
        A dictionary of variables to add to the template context. Any
        callable object in this dictionary will be called to produce
        the end result which appears in the context.
    
    ``template_name``
        A custom template to use.
    
    **Context:**
    
    ``account``
        The ``User`` object corresponding to the account, if the
        activation was successful. ``False`` if the activation was not
        successful.
    
    ``expiration_days``
        The number of days for which activation keys stay valid after
        registration.
    
    Any extra variables supplied in the ``extra_context`` argument
    (see above).
    
    **Template:**
    
    registration/activate.html or ``template_name`` keyword argument.
    
    t   accountt   expiration_dayst   context_instanceN(   t   lowerR   t   objectst   activate_usert   NoneR   t   itemst   callableR   R    t   ACCOUNT_ACTIVATION_DAYS(   t   requestt   activation_keyt   template_namet   extra_contextR   t   contextt   keyt   value(    (    s3   /var/www/Pootle/external_apps/registration/views.pyt   activate   s    .
 %
s#   registration/registration_form.htmlc   
      C   sä   |  i  d j oP | d |  i d |  i ƒ } | i ƒ  o$ | i ƒ  } t | p
 t d ƒ ƒ Sn
 | ƒ  } | d j o
 h  } n t |  ƒ } x; | i	 ƒ  D]- \ } }	 t
 |	 ƒ o
 |	 ƒ  p |	 | | <q™ Wt | h | d 6d | ƒS(   s¨  
    Allow a new user to register an account.
    
    Following successful registration, issue a redirect; by default,
    this will be whatever URL corresponds to the named URL pattern
    ``registration_complete``, which will be
    ``/accounts/register/complete/`` if using the included URLConf. To
    change this, point that named pattern at another URL, or pass your
    preferred URL as the keyword argument ``success_url``.
    
    By default, ``registration.forms.RegistrationForm`` will be used
    as the registration form; to change this, pass a different form
    class as the ``form_class`` keyword argument. The form class you
    specify must have a method ``save`` which will create and return
    the new ``User``.
    
    By default, use the template
    ``registration/registration_form.html``; to change this, pass the
    name of a template as the keyword argument ``template_name``.
    
    **Required arguments**
    
    None.
    
    **Optional arguments**
    
    ``form_class``
        The form class to use for registration.
    
    ``extra_context``
        A dictionary of variables to add to the template context. Any
        callable object in this dictionary will be called to produce
        the end result which appears in the context.
    
    ``success_url``
        The URL to redirect to on successful registration.
    
    ``template_name``
        A custom template to use.
    
    **Context:**
    
    ``form``
        The registration form.
    
    Any extra variables supplied in the ``extra_context`` argument
    (see above).
    
    **Template:**
    
    registration/registration_form.html or ``template_name`` keyword
    argument.
    
    t   POSTt   datat   filest   registration_completet   formR	   N(   t   methodR   t   FILESt   is_validt   saveR   R   R   R   R   R   R   (
   R   t   success_urlt
   form_classR   R   R   t   new_userR   R   R   (    (    s3   /var/www/Pootle/external_apps/registration/views.pyt   registerL   s    :	
 %N(   t   __doc__t   django.confR    t   django.core.urlresolversR   t   django.httpR   t   django.shortcutsR   t   django.templateR   t   registration.formsR   t   registration.modelsR   R   R   R%   (    (    (    s3   /var/www/Pootle/external_apps/registration/views.pyt   <module>   s   9