#NEWLINE# def post( self ) : #NEWLINE# #INDENT# form = self . form ( request . form ) #NEWLINE# if form . validate ( ) : #NEWLINE# #INDENT# user = get_current_user ( ) #NEWLINE# avatar_file_path = user . avatar_file_path #NEWLINE# avatar = request . files . get ( 'avatar' ) #NEWLINE# if avatar : #NEWLINE# #INDENT# filename = secure_filename ( avatar . filename ) #NEWLINE# avatar_file_path = os . path . join ( 'avatars' , str ( user . id ) , filename ) #NEWLINE# path = os . path . join ( lazy_media_path ( ) , avatar_file_path ) #NEWLINE# if ( not os . path . exists ( os . path . dirname ( avatar_file_path ) ) ) : #NEWLINE# #INDENT# os . makedirs ( os . path . dirname ( path ) , 511 ) #NEWLINE# #UNINDENT# avatar . save ( path ) #NEWLINE# #UNINDENT# form . populate_obj ( user ) #NEWLINE# user . avatar_file_path = avatar_file_path #NEWLINE# if avatar : #NEWLINE# #INDENT# user . use_avatar_from = 'upload' #NEWLINE# #UNINDENT# user . username = User . generate_username ( ( user . username or user . name ) , user = user ) #NEWLINE# self . update_user_links ( request . form , user ) #NEWLINE# user . save ( ) #NEWLINE# flash ( 'Profile saved!' , 'alert' ) #NEWLINE# return redirect ( ( request . args . get ( 'next' ) or url_for ( 'lingobarter.modules.accounts.profile_edit' ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# flash ( 'Error ocurred!' , 'alert error' ) #NEWLINE# return render_template ( 'accounts/profile_edit.html' , form = form )