Skip to content

Commit

Permalink
simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
bgruening committed Sep 24, 2016
1 parent 2d6854c commit eb4b58a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/galaxy/webapps/galaxy/api/user_preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ def edit_address(self, trans, cntrller, kwd):
country = util.restore_text(params.get('country', ''))
phone = util.restore_text(params.get('phone', ''))

error_status = True
if not short_desc:
message = 'Enter a short description for this address'
elif not name:
Expand All @@ -376,6 +377,7 @@ def edit_address(self, trans, cntrller, kwd):
elif not country:
message = 'Enter the country'
else:
error_status = False
address_obj.desc = short_desc
address_obj.name = name
address_obj.institution = institution
Expand All @@ -393,7 +395,8 @@ def edit_address(self, trans, cntrller, kwd):
new_kwd['id'] = trans.security.encode_id(user.id)

return self.user_info(cntrller, trans, new_kwd)
else:

if error_status:
status = 'error'

# Display the address form with the current values filled in
Expand Down Expand Up @@ -483,6 +486,7 @@ def new_address(self, trans, cntrller, kwd):
if not trans.app.config.allow_user_creation and not is_admin:
return trans.show_error_message('User registration is disabled. Please contact your local Galaxy administrator for an account.')

error_status = True
if not short_desc:
message = 'Enter a short description for this address'
elif not name:
Expand All @@ -500,6 +504,7 @@ def new_address(self, trans, cntrller, kwd):
elif not country:
message = 'Enter the country'
else:
error_status = False
user_address = trans.model.UserAddress(user=user,
desc=short_desc,
name=name,
Expand All @@ -517,7 +522,8 @@ def new_address(self, trans, cntrller, kwd):
if is_admin:
new_kwd['id'] = trans.security.encode_id(user.id)
return self.user_info(cntrller, trans, new_kwd)
else:

if error_status:
return {
'user_id': user_id,
'message': escape(message),
Expand Down

0 comments on commit eb4b58a

Please sign in to comment.