#NEWLINE# def init_app( app , test_config = None ) : #NEWLINE# #INDENT# app . config . from_object ( ( __name__ + '.ConfigClass' ) ) #NEWLINE# try : #NEWLINE# #INDENT# app . config . from_object ( 'local_settings' ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# if test_config : #NEWLINE# #INDENT# app . config . update ( test_config ) #NEWLINE# #UNINDENT# babel = Babel ( app ) #NEWLINE# mail = Mail ( home_page ) #NEWLINE# db . create_all ( ) #NEWLINE# db_adapter = SQLAlchemyAdapter ( db , User , UserInvitationClass = UserInvitation ) #NEWLINE# user_manager = UserManager ( db_adapter , app ) #NEWLINE# if ( not User . query . filter ( ( User . username == 'member' ) ) . first ( ) ) : #NEWLINE# #INDENT# user = User ( username = 'member' , email = 'member@example.com' , active = True , password = user_manager . hash_password ( 'Password1' ) , confirmed_at = datetime . datetime . utcnow ( ) ) #NEWLINE# db . session . add ( user ) #NEWLINE# db . session . commit ( ) #NEWLINE# #UNINDENT# if ( not User . query . filter ( ( User . username == 'user007' ) ) . first ( ) ) : #NEWLINE# #INDENT# user1 = User ( username = 'user007' , email = 'user007@example.com' , active = True , password = user_manager . hash_password ( 'Password1' ) ) #NEWLINE# user1 . roles . append ( Role ( name = 'secret' ) ) #NEWLINE# user1 . roles . append ( Role ( name = 'agent' ) ) #NEWLINE# db . session . add ( user1 ) #NEWLINE# db . session . commit ( ) #NEWLINE# #UNINDENT# @ app . route ( '/' ) #NEWLINE# def home_page( ) : #NEWLINE# #INDENT# return render_template_string ( '\n            {% extends "base.html" %}\n            {% block content %}\n            <h2>{%trans%}Home Page{%endtrans%}</h2>\n            <p><a href="{{ url_for(\'user.login\') }}">{%trans%}Sign in{%endtrans%}</a></p>\n            {% endblock %}\n            ' ) #NEWLINE# #UNINDENT# @ app . route ( '/user/profile' ) #NEWLINE# @ login_required #NEWLINE# @ confirm_email_required #NEWLINE# def user_profile_page( ) : #NEWLINE# #INDENT# return render_template_string ( '\n            {% extends "base.html" %}\n            {% block content %}\n            <h2>{%trans%}Profile Page{%endtrans%}</h2>\n            <p> {%trans%}Hello{%endtrans%}\n                {{ current_user.username or current_user.email }},</p>\n            <p> <a href="{{ url_for(\'user.change_username\') }}">\n                {%trans%}Change username{%endtrans%}</a></p>\n            <p> <a href="{{ url_for(\'user.change_password\') }}">\n                {%trans%}Change password{%endtrans%}</a></p>\n            <p> <a href="{{ url_for(\'user.invite\') }}">\n                {%trans%}Invite User{%endtrans%}</a></p>\n            <p> <a href="{{ url_for(\'user.logout\') }}?next={{ url_for(\'user.login\') }}">\n                {%trans%}Sign out{%endtrans%}</a></p>\n            {% endblock %}\n            ' ) #NEWLINE# #UNINDENT# @ app . route ( '/special' ) #NEWLINE# @ roles_required ( 'secret' , [ 'sauce' , 'agent' ] ) #NEWLINE# def special_page( ) : #NEWLINE# #INDENT# return render_template_string ( '\n            {% extends "base.html" %}\n            {% block content %}\n            <h2>{%trans%}Special Page{%endtrans%}</h2>\n            {% endblock %}\n            ' ) #NEWLINE# #UNINDENT# app . db = db #NEWLINE# app . UserEmailClass = UserEmail #NEWLINE# return app