<s> """<STR_LIT>""" <EOL> from annoying . decorators import render_to <EOL> from django . contrib import auth <EOL> from django . contrib . auth import authenticate , login <EOL> from django . conf import settings <EOL> from django . core . urlresolvers import reverse <EOL> from django . forms . util import ErrorList <EOL> from django . forms . forms import NON_FIELD_ERRORS <EOL> from django . http import HttpResponseRedirect <EOL> from django . template . context import RequestContext <EOL> from django . shortcuts import render_to_response <EOL> from tos . models import ( <EOL> has_user_agreed_latest_tos , TermsOfService , NoActiveTermsOfService <EOL> ) <EOL> from landing . forms import LoginForm , SetStrongPasswordForm <EOL> import logging <EOL> logger = logging . getLogger ( __name__ ) <EOL> @ render_to ( '<STR_LIT>' ) <EOL> def landing_page ( request ) : <EOL> if request . user . is_authenticated ( ) : <EOL> return HttpResponseRedirect ( reverse ( '<STR_LIT>' ) ) <EOL> login_form = LoginForm ( ) <EOL> return locals ( ) <EOL> def _login_view ( request ) : <EOL> """<STR_LIT>""" <EOL> if request . method == "<STR_LIT:POST>" : <EOL> redirect_to = request . REQUEST . get ( '<STR_LIT>' , False ) <EOL> if not redirect_to : <EOL> redirect_to = reverse ( '<STR_LIT>' ) <EOL> form = LoginForm ( request . POST ) <EOL> if form . is_valid ( ) : <EOL> new_user = authenticate ( <EOL> username = form . cleaned_data [ '<STR_LIT:email>' ] . lower ( ) , <EOL> password = form . cleaned_data [ '<STR_LIT:password>' ] <EOL> ) <EOL> if new_user and new_user . is_active : <EOL> try : <EOL> user_accepted_tos = has_user_agreed_latest_tos ( new_user ) <EOL> except NoActiveTermsOfService : <EOL> user_accepted_tos = True <EOL> if user_accepted_tos : <EOL> login ( request , new_user ) <EOL> return HttpResponseRedirect ( redirect_to ) <EOL> else : <EOL> request . session [ '<STR_LIT>' ] = new_user . pk <EOL> request . session [ '<STR_LIT>' ] = new_user . backend <EOL> context = RequestContext ( request ) <EOL> context . update ( { <EOL> '<STR_LIT>' : redirect_to , <EOL> '<STR_LIT>' : TermsOfService . objects . get_current_tos ( ) <EOL> } ) <EOL> return render_to_response ( <EOL> '<STR_LIT>' , <EOL> context_instance = context <EOL> ) <EOL> else : <EOL> errors = ErrorList ( ) <EOL> errors = form . _errors . setdefault ( NON_FIELD_ERRORS , errors ) <EOL> errors . append ( '<STR_LIT>' ) <EOL> else : <EOL> form = LoginForm ( ) <EOL> return locals ( ) <EOL> login_view = render_to ( '<STR_LIT>' ) ( _login_view ) <EOL> def password_set ( request , uidb64 = None , token = None ) : <EOL> return auth . views . password_reset_confirm ( <EOL> request , <EOL> uidb64 = uidb64 , <EOL> token = token , <EOL> template_name = '<STR_LIT>' , <EOL> post_reset_redirect = reverse ( '<STR_LIT>' ) <EOL> ) <EOL> def password_reset ( request ) : <EOL> return auth . views . password_reset ( <EOL> request , template_name = '<STR_LIT>' , <EOL> subject_template_name = '<STR_LIT>' , <EOL> email_template_name = '<STR_LIT>' , <EOL> post_reset_redirect = reverse ( '<STR_LIT>' ) , <EOL> from_email = settings . PASSWORD_RESET_EMAIL , <EOL> is_admin_site = True , <EOL> ) <EOL> def password_reset_done ( request ) : <EOL> return auth . views . password_reset_done ( <EOL> request , <EOL> template_name = '<STR_LIT>' <EOL> ) <EOL> def password_reset_confirm ( request , uidb64 = None , token = None ) : <EOL> return auth . views . password_reset_confirm ( <EOL> request , <EOL> uidb64 = uidb64 , <EOL> token = token , <EOL> template_name = '<STR_LIT>' , <EOL> set_password_form = SetStrongPasswordForm , <EOL> post_reset_redirect = reverse ( '<STR_LIT>' ) <EOL> ) <EOL> @ render_to ( "<STR_LIT>" ) <EOL> def password_reset_complete ( request ) : <EOL> return locals ( ) <EOL> def signup ( request , uidb64 = None , token = None ) : <EOL> return auth . views . password_reset_confirm ( <EOL> request , <EOL> uidb64 = uidb64 , <EOL> token = token , <EOL> template_name = '<STR_LIT>' , <EOL> set_password_form = SetStrongPasswordForm , <EOL> post_reset_redirect = reverse ( '<STR_LIT>' ) + "<STR_LIT>" <EOL> ) </s>
