From e20cf00c91b304ae7b1b196de599c79026006d56 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Thu, 8 Mar 2007 17:31:28 +0000 Subject: [PATCH] "User" relation interface: normalizing form styles and such to be consistent with the rest of the application. --- lib/galaxy/interfaces/user.py | 61 +++++++++++++++++------------------ templates/user_account.tmpl | 44 +++++++++---------------- 2 files changed, 45 insertions(+), 60 deletions(-) diff --git a/lib/galaxy/interfaces/user.py b/lib/galaxy/interfaces/user.py index e24252e44d1..2a0dfe49408 100644 --- a/lib/galaxy/interfaces/user.py +++ b/lib/galaxy/interfaces/user.py @@ -27,20 +27,20 @@ class User( common.Root ): old_pass_err = new_pass_err = conf_pass_err = '' user = trans.get_user() if not user: - trans.response.send_redirect("/user/login") - - if not user.check_password( old_pass ): - old_pass_err = "Invalid password" - elif len( new_pass ) < 6: - new_pass_err = "Please use a password of at least 6 characters" - elif new_pass != conf_pass: - conf_pass_err = "New passwords do not match." - else: - user.set_password_cleartext( new_pass ) - user.flush() - trans.log_event( "User change password" ) - return trans.show_ok_message( "Password has been changed for " + user.email) - + trans.response.send_redirect( "/user/login" ) + if trans.request.method == 'POST': + if not user.check_password( old_pass ): + old_pass_err = "Invalid password" + elif len( new_pass ) < 6: + new_pass_err = "Please use a password of at least 6 characters" + elif new_pass != conf_pass: + conf_pass_err = "New passwords do not match." + else: + user.set_password_cleartext( new_pass ) + user.flush() + trans.log_event( "User change password" ) + return trans.show_ok_message( "Password has been changed for " + user.email) + # Generate input form return trans.show_form( web.FormBuilder( "/user/change_password", "Change Password", submit_text="Submit" ) .add_password( "old_pass", "Old Password", value='', error=old_pass_err ) @@ -53,23 +53,22 @@ class User( common.Root ): user = trans.get_user() if not user: trans.response.send_redirect("/user/login") - - if not user.check_password( password ): - pass_err = "Invalid password" - elif len( email ) == 0 or "@" not in email or "." not in email: - email_err = "Please enter a real email address" - elif len( email) > 255: - email_err = "Email address exceeds maximum allowable length" - elif len( trans.app.model.User.select_by( email=email ) ) > 0: - email_err = "User with that email already exists" - elif email != conf_email: - conf_email_err = "Email addresses do not match." - else: - user.email = email - user.flush() - trans.log_event( "User change email" ) - return trans.show_ok_message( "Email has been changed to: " + user.email, refresh_frames=['masthead', 'history'] ) - + if trans.request.method == "POST": + if not user.check_password( password ): + pass_err = "Invalid password" + elif len( email ) == 0 or "@" not in email or "." not in email: + email_err = "Please enter a real email address" + elif len( email) > 255: + email_err = "Email address exceeds maximum allowable length" + elif len( trans.app.model.User.select_by( email=email ) ) > 0: + email_err = "User with that email already exists" + elif email != conf_email: + conf_email_err = "Email addresses do not match." + else: + user.email = email + user.flush() + trans.log_event( "User change email" ) + return trans.show_ok_message( "Email has been changed to: " + user.email, refresh_frames=['masthead', 'history'] ) return trans.show_form( web.FormBuilder( "/user/change_email", "Change Email", submit_text="Submit" ) .add_text( "email", "Email", value=email, error=email_err ) diff --git a/templates/user_account.tmpl b/templates/user_account.tmpl index 464c1e8528f..7708393cd29 100644 --- a/templates/user_account.tmpl +++ b/templates/user_account.tmpl @@ -11,38 +11,24 @@
-
User settings for $user.email
+

User settings for $user.email

#if $msg:

$msg

#end if -
-
- - - - - - - - - - - - - - - - -
Change Your Password
Current Password:
New Password:
Confirm Password:
Update Your Email
New Email:
Confirm Email:
Password:
Actions
-
    -
  • View your available histories
  • -
  • Store your current history
  • -
  • Delete your current history
  • -
    -
  • Logout
  • -
-
-
+ +

Account settings

+ +

Histories

+ +
\ No newline at end of file