Skip to content

Commit

Permalink
Use single api endpoint to build user information form with addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Sep 30, 2016
1 parent 15081cf commit ee8a887
Showing 1 changed file with 16 additions and 30 deletions.
46 changes: 16 additions & 30 deletions lib/galaxy/webapps/galaxy/api/user_preferences.py
Expand Up @@ -37,7 +37,8 @@ def index( self, trans, **kwd ):
'quota' : trans.app.quota_agent.get_quota( trans.user, nice_size=True )
}

def user_info( self, trans, kwd ):
@expose_api
def manage_user_info( self, trans, **kwd ):
'''
Manage a user login, password, public username, type, addresses, etc.
'''
Expand Down Expand Up @@ -101,39 +102,24 @@ def user_info( self, trans, kwd ):
address_inputs.append( input_copy )
address_repeat[ 'cache' ].append( address_inputs )
inputs.append( address_repeat )
return {
'webapp' : trans.webapp.name,
'user_id' : trans.security.encode_id( trans.user.id ),
'is_admin' : trans.user_is_admin(),
'values' : user.values,
'email' : email,
'username' : username,
'addresses' : [ address.to_dict( trans ) for address in user.addresses ],
'inputs' : inputs,
}
else:
if user.active_repositories:
form.append(dict(id='name_input', name='username', label='Public name:', type='hidden', value=username, help='You cannot change your public name after you have created a repository in this tool shed.'))
inputs.append(dict(id='name_input', name='username', label='Public name:', type='hidden', value=username, help='You cannot change your public name after you have created a repository in this tool shed.'))
else:
form.append(dict(id='name_input', name='username', label='Public name:', type='text', value=username, help='Your public name provides a means of identifying you publicly within this tool shed. Public names must be at least three characters in length and contain only lower-case letters, numbers, and the "-" character. You cannot change your public name after you have created a repository in this tool shed.'))

return {
'cntrller': cntrller,
'webapp': trans.webapp.name,
'user_id': trans.security.encode_id(trans.user.id),
'is_admin': trans.user_is_admin(),
'active_repositories': user.active_repositories,
'email': email,
'username': username,
'message': message,
'status': status,
'form': form
}
inputs.append(dict(id='name_input', name='username', label='Public name:', type='text', value=username, help='Your public name provides a means of identifying you publicly within this tool shed. Public names must be at least three characters in length and contain only lower-case letters, numbers, and the "-" character. You cannot change your public name after you have created a repository in this tool shed.'))
return {
'webapp' : trans.webapp.name,
'user_id' : trans.security.encode_id( trans.user.id ),
'is_admin' : trans.user_is_admin(),
'values' : user.values,
'email' : email,
'username' : username,
'addresses' : [ address.to_dict( trans ) for address in user.addresses ],
'inputs' : inputs,
}

@expose_api
def manage_user_info( self, trans, **kwd ):
""" Manage User Info API call """
return self.user_info( trans, kwd )
def user_info( self, trans, kwd ):
return {}

def edit_info(self, trans, cntrller, kwd):
"""
Expand Down

0 comments on commit ee8a887

Please sign in to comment.