mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-29 17:42:12 +08:00
Fixed as many of the issues as could be found throughout the framework due to the migration of FormValues.content from a list to a dictionary in change set 4744 b73ad3906e24.
This commit is contained in:
@@ -1510,8 +1510,13 @@ class FormDefinition( object, APIItem ):
|
||||
widgets = []
|
||||
for index, field in enumerate( self.fields ):
|
||||
field_type = field[ 'type' ]
|
||||
field_name = 'field_%i' % index
|
||||
# determine the value of the field
|
||||
if 'name' in field:
|
||||
field_name = field[ 'name' ]
|
||||
else:
|
||||
# Default to names like field_0, field_1, etc for backward compatibility
|
||||
# (not sure this is necessary)...
|
||||
field_name = 'field_%i' % index
|
||||
# Determine the value of the field
|
||||
if field_name in kwd:
|
||||
# The form was submitted via refresh_on_change
|
||||
if field_type == 'CheckboxField':
|
||||
@@ -1525,20 +1530,24 @@ class FormDefinition( object, APIItem ):
|
||||
except:
|
||||
# If there was an error getting the saved value, we'll still
|
||||
# display the widget, but it will be empty.
|
||||
if field_type == 'CheckboxField':
|
||||
if field_type == 'AddressField':
|
||||
value = 'none'
|
||||
elif field_type == 'CheckboxField':
|
||||
# Since we do not have contents, set checkbox value to False
|
||||
value = False
|
||||
else:
|
||||
# Set other field types to empty string
|
||||
value = ''
|
||||
value = ''
|
||||
else:
|
||||
# if none of the above, then leave the field empty
|
||||
if field_type == 'CheckboxField':
|
||||
# If none of the above, then leave the field empty
|
||||
if field_type == 'AddressField':
|
||||
value = 'none'
|
||||
elif field_type == 'CheckboxField':
|
||||
# Since we do not have contents, set checkbox value to False
|
||||
value = False
|
||||
else:
|
||||
# Set other field types to the default value of the field
|
||||
value = field.get('default', '')
|
||||
value = field.get( 'default', '' )
|
||||
# Create the field widget
|
||||
field_widget = eval( field_type )( field_name )
|
||||
if field_type == 'TextField':
|
||||
|
||||
@@ -37,23 +37,23 @@ def persist_uploads( params ):
|
||||
def handle_library_params( trans, params, folder_id, replace_dataset=None ):
|
||||
# FIXME: the received params has already been parsed by util.Params() by the time it reaches here,
|
||||
# so no complex objects remain. This is not good because it does not allow for those objects to be
|
||||
# manipulated here. The receivd params should be the original kwd from the initial request.
|
||||
# manipulated here. The received params should be the original kwd from the initial request.
|
||||
library_bunch = util.bunch.Bunch()
|
||||
library_bunch.replace_dataset = replace_dataset
|
||||
library_bunch.message = params.get( 'ldda_message', '' )
|
||||
# See if we have any template field contents
|
||||
library_bunch.template_field_contents = []
|
||||
library_bunch.template_field_contents = {}
|
||||
template_id = params.get( 'template_id', None )
|
||||
library_bunch.folder = trans.sa_session.query( trans.app.model.LibraryFolder ).get( trans.security.decode_id( folder_id ) )
|
||||
# We are inheriting the folder's info_association, so we may have received inherited contents or we may have redirected
|
||||
# here after the user entered template contents ( due to errors ).
|
||||
if template_id not in [ None, 'None' ]:
|
||||
library_bunch.template = trans.sa_session.query( trans.app.model.FormDefinition ).get( template_id )
|
||||
for field_index in range( len( library_bunch.template.fields ) ):
|
||||
field_name = 'field_%i' % field_index
|
||||
for field in library_bunch.template.fields:
|
||||
field_name = field[ 'name' ]
|
||||
if params.get( field_name, False ):
|
||||
field_value = util.restore_text( params.get( field_name, '' ) )
|
||||
library_bunch.template_field_contents.append( field_value )
|
||||
library_bunch.template_field_contents[ field_name ] = field_value
|
||||
else:
|
||||
library_bunch.template = None
|
||||
library_bunch.roles = []
|
||||
|
||||
@@ -289,6 +289,7 @@ class UsesFormDefinitions:
|
||||
return forms
|
||||
@web.expose
|
||||
def add_template( self, trans, cntrller, item_type, form_type, **kwd ):
|
||||
log.debug("#### IN add_template, kwd: %s" % str( kwd ))
|
||||
params = util.Params( kwd )
|
||||
form_id = params.get( 'form_id', 'none' )
|
||||
message = util.restore_text( params.get( 'message', '' ) )
|
||||
@@ -364,7 +365,7 @@ class UsesFormDefinitions:
|
||||
if params.get( 'add_template_button', False ):
|
||||
if form_id not in [ None, 'None', 'none' ]:
|
||||
form = trans.sa_session.query( trans.app.model.FormDefinition ).get( trans.security.decode_id( form_id ) )
|
||||
form_values = trans.app.model.FormValues( form, [] )
|
||||
form_values = trans.app.model.FormValues( form, {} )
|
||||
trans.sa_session.add( form_values )
|
||||
trans.sa_session.flush()
|
||||
if item_type == 'library':
|
||||
@@ -417,6 +418,7 @@ class UsesFormDefinitions:
|
||||
decoded_form_id = trans.security.decode_id( form_id )
|
||||
except:
|
||||
decoded_form_id = None
|
||||
log.debug("#### IN add_template, decoded_form_id: %s" % str( decoded_form_id ))
|
||||
if decoded_form_id:
|
||||
for form in forms:
|
||||
if decoded_form_id == form.id:
|
||||
@@ -443,6 +445,7 @@ class UsesFormDefinitions:
|
||||
ldda_id=ldda_id,
|
||||
inheritable_checked=inheritable,
|
||||
show_deleted=show_deleted ) )
|
||||
log.debug("#### IN add_template, widgets: %s" % str( widgets ))
|
||||
return trans.fill_template( '/common/select_template.mako',
|
||||
**new_kwd )
|
||||
@web.expose
|
||||
@@ -502,6 +505,7 @@ class UsesFormDefinitions:
|
||||
info_association = rtra.run
|
||||
template = info_association.template
|
||||
info = info_association.info
|
||||
log.debug("&&&&&&&&In edit_template, info: %s" % str( info ))
|
||||
form_values = trans.sa_session.query( trans.app.model.FormValues ).get( info.id )
|
||||
if edited:
|
||||
# The form on which the template is based has been edited, so we need to update the
|
||||
@@ -540,6 +544,7 @@ class UsesFormDefinitions:
|
||||
return trans.response.send_redirect( web.url_for( controller='forms', action='edit_form_definition', **vars ) )
|
||||
@web.expose
|
||||
def edit_template_info( self, trans, cntrller, item_type, form_type, **kwd ):
|
||||
log.debug(">>>>>>>>>>>In edit_template_info, kwd: %s" % str( kwd ))
|
||||
# Edit the contents of the template fields without altering the template itself.
|
||||
params = util.Params( kwd )
|
||||
# form_type must be one of: RUN_DETAILS_TEMPLATE, LIBRARY_INFO_TEMPLATE
|
||||
@@ -586,17 +591,21 @@ class UsesFormDefinitions:
|
||||
status='error' ) )
|
||||
# We need the type of each template field widget
|
||||
widgets = item.get_template_widgets( trans )
|
||||
log.debug(">>>>>>>>>>>In edit_template_info, widgets: %s" % str( widgets ))
|
||||
# The list of widgets may include an AddressField which we need to save if it is new
|
||||
for index, widget_dict in enumerate( widgets ):
|
||||
log.debug(">>>>>>>>>>>In edit_template_info, index: %s" % str( index ))
|
||||
log.debug(">>>>>>>>>>>In edit_template_info, widget_dict: %s" % str( widget_dict ))
|
||||
widget = widget_dict[ 'widget' ]
|
||||
if isinstance( widget, AddressField ):
|
||||
value = util.restore_text( params.get( 'field_%i' % index, '' ) )
|
||||
#value = util.restore_text( params.get( 'field_%i' % index, '' ) )
|
||||
value = util.restore_text( params.get( widget.name, '' ) )
|
||||
if value == 'new':
|
||||
if params.get( 'edit_info_button', False ):
|
||||
if self.field_param_values_ok( index, 'AddressField', **kwd ):
|
||||
if self.field_param_values_ok( widget.name, 'AddressField', **kwd ):
|
||||
# Save the new address
|
||||
address = trans.app.model.UserAddress( user=trans.user )
|
||||
self.save_widget_field( trans, address, index, **kwd )
|
||||
self.save_widget_field( trans, address, widget.name, **kwd )
|
||||
widget.value = str( address.id )
|
||||
else:
|
||||
message = 'Required fields are missing contents.'
|
||||
@@ -627,13 +636,17 @@ class UsesFormDefinitions:
|
||||
elif isinstance( widget, CheckboxField ):
|
||||
# We need to check the value from kwd since util.Params would have munged the list if
|
||||
# the checkbox is checked.
|
||||
value = kwd.get( 'field_%i' % index, '' )
|
||||
#value = kwd.get( 'field_%i' % index, '' )
|
||||
value = kwd.get( widget.name, '' )
|
||||
if CheckboxField.is_checked( value ):
|
||||
widget.value = 'true'
|
||||
else:
|
||||
widget.value = util.restore_text( params.get( 'field_%i' % index, '' ) )
|
||||
#widget.value = util.restore_text( params.get( 'field_%i' % index, '' ) )
|
||||
widget.value = util.restore_text( params.get( widget.name, '' ) )
|
||||
log.debug(">>>>>>>>>>>In edit_template_info, widget.value: %s" % str( widget.value ))
|
||||
# Save updated template field contents
|
||||
field_contents = self.clean_field_contents( widgets, **kwd )
|
||||
log.debug(">>>>>>>>>>>In edit_template_info, field_contents: %s" % str( field_contents ))
|
||||
if field_contents:
|
||||
if in_library:
|
||||
# In in a library, since information templates are inherited, the template fields can be displayed
|
||||
@@ -654,7 +667,7 @@ class UsesFormDefinitions:
|
||||
# create a SampleRunAssociation using the inherited template from the RequestType.
|
||||
if isinstance( assoc, trans.model.RequestTypeRunAssociation ):
|
||||
form_definition = assoc.run.template
|
||||
new_form_values = trans.model.FormValues( form_definition, [] )
|
||||
new_form_values = trans.model.FormValues( form_definition, {} )
|
||||
trans.sa_session.add( new_form_values )
|
||||
trans.sa_session.flush()
|
||||
new_run = trans.model.Run( form_definition, new_form_values )
|
||||
@@ -671,12 +684,26 @@ class UsesFormDefinitions:
|
||||
if info_association:
|
||||
template = info_association.template
|
||||
info = info_association.info
|
||||
log.debug(">>>>>>>>>>>In edit_template_info, info: %s" % str( info ))
|
||||
log.debug(">>>>>>>>>>>In edit_template_info, info.content: %s" % str( info.content ))
|
||||
form_values = trans.sa_session.query( trans.app.model.FormValues ).get( info.id )
|
||||
log.debug(">>>>>>>>>>>In edit_template_info, form_values.content 1: %s" % str( form_values.content ))
|
||||
# Update existing content only if it has changed
|
||||
if form_values.content != field_contents:
|
||||
form_values.content = field_contents
|
||||
flush_required = False
|
||||
for field_contents_key, field_contents_value in field_contents.items():
|
||||
log.debug(">>>>>>>>>>>In edit_template_info, field_contents_key: %s" % str( field_contents_key ))
|
||||
log.debug(">>>>>>>>>>>In edit_template_info, field_contents_value: %s" % str( field_contents_value ))
|
||||
if field_contents_key in form_values.content:
|
||||
if form_values.content[ field_contents_key ] != field_contents_value:
|
||||
flush_required = True
|
||||
form_values.content[ field_contents_key ] = field_contents_value
|
||||
else:
|
||||
flush_required = True
|
||||
form_values.content[ field_contents_key ] = field_contents_value
|
||||
if flush_required:
|
||||
trans.sa_session.add( form_values )
|
||||
trans.sa_session.flush()
|
||||
log.debug(">>>>>>>>>>>In edit_template_info, form_values.content 2: %s" % str( form_values.content ))
|
||||
else:
|
||||
if in_library:
|
||||
# Inherit the next available info_association so we can get the template
|
||||
@@ -802,10 +829,14 @@ class UsesFormDefinitions:
|
||||
# Return True if any of the fields in widgets contain contents, widgets is a list of dictionaries that looks something like:
|
||||
# [{'widget': <galaxy.web.form_builder.TextField object at 0x10867aa10>, 'helptext': 'Field 0 help (Optional)', 'label': 'Field 0'}]
|
||||
for i, field in enumerate( widgets ):
|
||||
#log.debug("VVVVVVVV In widget_fields_have_contents, field: %s" % str( field ))
|
||||
#log.debug("VVVVVVVV In widget_fields_have_contents, field[ 'widget' ]: %s" % str( field[ 'widget' ] ))
|
||||
#log.debug("VVVVVVVV In widget_fields_have_contents, field[ 'widget' ].value: %s" % str( field[ 'widget' ].value ))
|
||||
if ( isinstance( field[ 'widget' ], TextArea ) or isinstance( field[ 'widget' ], TextField ) ) and field[ 'widget' ].value:
|
||||
#log.debug("VVVVVVVV In widget_fields_have_contents, returning True...." )
|
||||
return True
|
||||
if isinstance( field[ 'widget' ], SelectField ) and field[ 'widget' ].options:
|
||||
for option_label, option_value, selected in field['widget'].options:
|
||||
for option_label, option_value, selected in field[ 'widget' ].options:
|
||||
if selected:
|
||||
return True
|
||||
if isinstance( field[ 'widget' ], CheckboxField ) and field[ 'widget' ].checked:
|
||||
@@ -814,11 +845,14 @@ class UsesFormDefinitions:
|
||||
return True
|
||||
if isinstance( field[ 'widget' ], HistoryField ) and str( field[ 'widget' ].value ).lower() not in [ 'none' ]:
|
||||
return True
|
||||
#log.debug("VVVVVVVV In widget_fields_have_contents, str( field[ 'widget' ].value ).lower(): *%s*" % str( str( field[ 'widget' ].value ).lower() ))
|
||||
if isinstance( field[ 'widget' ], AddressField ) and str( field[ 'widget' ].value ).lower() not in [ 'none' ]:
|
||||
return True
|
||||
return False
|
||||
def clean_field_contents( self, widgets, **kwd ):
|
||||
field_contents = []
|
||||
log.debug("=====In clean_field_contents, widgets: %s" % str( widgets ))
|
||||
log.debug("=====In clean_field_contents, kwd: %s" % str( kwd ))
|
||||
field_contents = {}
|
||||
for index, widget_dict in enumerate( widgets ):
|
||||
widget = widget_dict[ 'widget' ]
|
||||
value = kwd.get( widget.name, '' )
|
||||
@@ -828,65 +862,74 @@ class UsesFormDefinitions:
|
||||
elif isinstance( widget, AddressField ):
|
||||
# If the address was new, is has already been saved and widget.value is the new address.id
|
||||
value = widget.value
|
||||
field_contents.append( util.restore_text( value ) )
|
||||
field_contents[ widget.name ] = util.restore_text( value )
|
||||
log.debug("=====In clean_field_contents, returning field_contents: %s" % str( field_contents ))
|
||||
return field_contents
|
||||
def field_param_values_ok( self, index, widget_type, **kwd ):
|
||||
def field_param_values_ok( self, widget_name, widget_type, **kwd ):
|
||||
log.debug("++++++In field_param_values_ok, widget_name: %s" % str( widget_name ))
|
||||
log.debug("++++++In field_param_values_ok, widget_type: %s" % str( widget_type ))
|
||||
log.debug("++++++In field_param_values_ok, kwd: %s" % str( kwd ))
|
||||
# Make sure required fields have contents, etc
|
||||
params = util.Params( kwd )
|
||||
if widget_type == 'AddressField':
|
||||
if not util.restore_text( params.get( 'field_%i_short_desc' % index, '' ) ) \
|
||||
or not util.restore_text( params.get( 'field_%i_name' % index, '' ) ) \
|
||||
or not util.restore_text( params.get( 'field_%i_institution' % index, '' ) ) \
|
||||
or not util.restore_text( params.get( 'field_%i_address' % index, '' ) ) \
|
||||
or not util.restore_text( params.get( 'field_%i_city' % index, '' ) ) \
|
||||
or not util.restore_text( params.get( 'field_%i_state' % index, '' ) ) \
|
||||
or not util.restore_text( params.get( 'field_%i_postal_code' % index, '' ) ) \
|
||||
or not util.restore_text( params.get( 'field_%i_country' % index, '' ) ):
|
||||
if not util.restore_text( params.get( '%s_short_desc' % widget_name, '' ) ) \
|
||||
or not util.restore_text( params.get( '%s_name' % widget_name, '' ) ) \
|
||||
or not util.restore_text( params.get( '%s_institution' % widget_name, '' ) ) \
|
||||
or not util.restore_text( params.get( '%s_address' % widget_name, '' ) ) \
|
||||
or not util.restore_text( params.get( '%s_city' % widget_name, '' ) ) \
|
||||
or not util.restore_text( params.get( '%s_state' % widget_name, '' ) ) \
|
||||
or not util.restore_text( params.get( '%s_postal_code' % widget_name, '' ) ) \
|
||||
or not util.restore_text( params.get( '%s_country' % widget_name, '' ) ):
|
||||
return False
|
||||
return True
|
||||
def save_widget_field( self, trans, field_obj, index, **kwd ):
|
||||
def save_widget_field( self, trans, field_obj, widget_name, **kwd ):
|
||||
log.debug("<<<<<<<<In save_widget_field, field_obj: %s" % str( field_obj ))
|
||||
log.debug("<<<<<<<<In save_widget_field, widget_name: %s" % str( widget_name ))
|
||||
log.debug("<<<<<<<<In save_widget_field, kwd: %s" % str( kwd ))
|
||||
# Save a form_builder field object
|
||||
params = util.Params( kwd )
|
||||
if isinstance( field_obj, trans.model.UserAddress ):
|
||||
field_obj.desc = util.restore_text( params.get( 'field_%i_short_desc' % index, '' ) )
|
||||
field_obj.name = util.restore_text( params.get( 'field_%i_name' % index, '' ) )
|
||||
field_obj.institution = util.restore_text( params.get( 'field_%i_institution' % index, '' ) )
|
||||
field_obj.address = util.restore_text( params.get( 'field_%i_address' % index, '' ) )
|
||||
field_obj.city = util.restore_text( params.get( 'field_%i_city' % index, '' ) )
|
||||
field_obj.state = util.restore_text( params.get( 'field_%i_state' % index, '' ) )
|
||||
field_obj.postal_code = util.restore_text( params.get( 'field_%i_postal_code' % index, '' ) )
|
||||
field_obj.country = util.restore_text( params.get( 'field_%i_country' % index, '' ) )
|
||||
field_obj.phone = util.restore_text( params.get( 'field_%i_phone' % index, '' ) )
|
||||
field_obj.desc = util.restore_text( params.get( '%s_short_desc' % widget_name, '' ) )
|
||||
field_obj.name = util.restore_text( params.get( '%s_name' % widget_name, '' ) )
|
||||
field_obj.institution = util.restore_text( params.get( '%s_institution' % widget_name, '' ) )
|
||||
field_obj.address = util.restore_text( params.get( '%s_address' % widget_name, '' ) )
|
||||
field_obj.city = util.restore_text( params.get( '%s_city' % widget_name, '' ) )
|
||||
field_obj.state = util.restore_text( params.get( '%s_state' % widget_name, '' ) )
|
||||
field_obj.postal_code = util.restore_text( params.get( '%s_postal_code' % widget_name, '' ) )
|
||||
field_obj.country = util.restore_text( params.get( '%s_country' % widget_name, '' ) )
|
||||
field_obj.phone = util.restore_text( params.get( '%s_phone' % widget_name, '' ) )
|
||||
trans.sa_session.add( field_obj )
|
||||
trans.sa_session.flush()
|
||||
def populate_widgets_from_kwd( self, trans, widgets, **kwd ):
|
||||
log.debug("^^^^^^^^In populate_widgets_from_kwd, widgets: %s" % str( widgets ))
|
||||
log.debug("^^^^^^^^In populate_widgets_from_kwd, kwd: %s" % str( kwd ))
|
||||
# A form submitted via refresh_on_change requires us to populate the widgets with the contents of
|
||||
# the form fields the user may have entered so that when the form refreshes the contents are retained.
|
||||
params = util.Params( kwd )
|
||||
populated_widgets = []
|
||||
for widget_dict in widgets:
|
||||
widget = widget_dict[ 'widget' ]
|
||||
log.debug("^^^^^^^^In populate_widgets_from_kwd, widget 1: %s" % str( widget ))
|
||||
log.debug("^^^^^^^^In populate_widgets_from_kwd, widget.name 1: %s" % str( widget.name ))
|
||||
#log.debug("^^^^^^^^In populate_widgets_from_kwd, widget.value 1: %s" % str( widget.value ))
|
||||
if params.get( widget.name, False ):
|
||||
# The form included a field whose contents should be used to set the
|
||||
# value of the current widget (widget.name is field_0, field_1, etc).
|
||||
if isinstance( widget, AddressField ):
|
||||
value = util.restore_text( params.get( widget.name, '' ) )
|
||||
if value == 'new':
|
||||
# Adding a new address
|
||||
widget.value = value
|
||||
widget_dict[ 'widget' ] = widget
|
||||
elif value == 'none':
|
||||
widget.value = ''
|
||||
widget_dict[ 'widget' ] = widget
|
||||
else:
|
||||
# An existing address object was selected
|
||||
widget_dict[ 'widget' ] = widget
|
||||
log.debug("^^^^^^^^In populate_widgets_from_kwd, value: %s" % str( value ))
|
||||
if value == 'none':
|
||||
value = ''
|
||||
widget.value = value
|
||||
log.debug("^^^^^^^^In populate_widgets_from_kwd, widget.value 2: %s" % str( widget.value ))
|
||||
widget_dict[ 'widget' ] = widget
|
||||
# Populate the AddressField params with the form field contents
|
||||
widget_params_dict = {}
|
||||
for field_name, label, help_text in widget.fields():
|
||||
form_param_name = '%s_%s' % ( widget.name, field_name )
|
||||
widget_params_dict[ form_param_name ] = util.restore_text( params.get( form_param_name, '' ) )
|
||||
widget.params = widget_params_dict
|
||||
log.debug("^^^^^^^^In populate_widgets_from_kwd, widget.params: %s" % str( widget.params ))
|
||||
elif isinstance( widget, CheckboxField ):
|
||||
# Check the value from kwd since util.Params would have
|
||||
# stringify'd the list if the checkbox is checked.
|
||||
@@ -904,6 +947,7 @@ class UsesFormDefinitions:
|
||||
widget.options = processed_options
|
||||
else:
|
||||
widget.value = util.restore_text( params.get( widget.name, '' ) )
|
||||
log.debug("^^^^^^^^In populate_widgets_from_kwd, widget.value 3: %s" % str( widget.value ))
|
||||
widget_dict[ 'widget' ] = widget
|
||||
populated_widgets.append( widget_dict )
|
||||
return populated_widgets
|
||||
|
||||
@@ -777,12 +777,12 @@ class LibraryCommon( BaseController, UsesFormDefinitions ):
|
||||
for index, widget_dict in enumerate( widgets ):
|
||||
widget = widget_dict[ 'widget' ]
|
||||
if isinstance( widget, AddressField ):
|
||||
value = util.restore_text( params.get( 'field_%i' % index, '' ) )
|
||||
value = util.restore_text( params.get( widget.name, '' ) )
|
||||
if value == 'new':
|
||||
if self.field_param_values_ok( index, 'AddressField', **kwd ):
|
||||
if self.field_param_values_ok( widget.name, 'AddressField', **kwd ):
|
||||
# Save the new address
|
||||
address = trans.app.model.UserAddress( user=trans.user )
|
||||
self.save_widget_field( trans, address, index, **kwd )
|
||||
self.save_widget_field( trans, address, widget.name, **kwd )
|
||||
widget.value = str( address.id )
|
||||
widget_dict[ 'widget' ] = widget
|
||||
processed_widgets.append( widget_dict )
|
||||
@@ -791,7 +791,7 @@ class LibraryCommon( BaseController, UsesFormDefinitions ):
|
||||
# method below calls the handle_library_params() method, which does not parse the
|
||||
# widget fields, it instead pulls form values from kwd. See the FIXME comments in the
|
||||
# handle_library_params() method, and the CheckboxField code in the next conditional.
|
||||
kwd[ 'field_%i' % index ] = str( address.id )
|
||||
kwd[ widget.name ] = str( address.id )
|
||||
else:
|
||||
# The invalid address won't be saved, but we cannot display error
|
||||
# messages on the upload form due to the ajax upload already occurring.
|
||||
@@ -802,12 +802,13 @@ class LibraryCommon( BaseController, UsesFormDefinitions ):
|
||||
elif isinstance( widget, CheckboxField ):
|
||||
# We need to check the value from kwd since util.Params would have munged the list if
|
||||
# the checkbox is checked.
|
||||
value = kwd.get( 'field_%i' % index, '' )
|
||||
value = kwd.get( widget.name, '' )
|
||||
if CheckboxField.is_checked( value ):
|
||||
widget.value = 'true'
|
||||
widget_dict[ 'widget' ] = widget
|
||||
processed_widgets.append( widget_dict )
|
||||
kwd[ 'field_%i' % index ] = 'true'
|
||||
#kwd[ 'field_%i' % index ] = 'true'
|
||||
kwd[ widget.name ] = 'true'
|
||||
else:
|
||||
processed_widgets.append( widget_dict )
|
||||
widgets = processed_widgets
|
||||
@@ -978,7 +979,7 @@ class LibraryCommon( BaseController, UsesFormDefinitions ):
|
||||
message = '"allow_library_path_paste" is not defined in the Galaxy configuration file'
|
||||
# Some error handling should be added to this method.
|
||||
try:
|
||||
# FIXME: instead of passing params here ( chiech have been process by util.Params(), the original kwd
|
||||
# FIXME: instead of passing params here ( which have been processed by util.Params(), the original kwd
|
||||
# should be passed so that complex objects that may have been included in the initial request remain.
|
||||
library_bunch = upload_common.handle_library_params( trans, params, folder_id, replace_dataset )
|
||||
except:
|
||||
|
||||
@@ -313,13 +313,13 @@ class RequestsCommon( BaseController, UsesFormDefinitions ):
|
||||
for index, field in enumerate( request_type.request_form.fields ):
|
||||
field_type = field[ 'type' ]
|
||||
field_name = field[ 'name' ]
|
||||
input_value = params.get( 'field_%i' % index, '' )
|
||||
if field[ 'type' ] == 'AddressField':
|
||||
input_value = params.get( field_name, '' )
|
||||
if field_type == 'AddressField':
|
||||
input_text_value = util.restore_text( input_value )
|
||||
if input_text_value == 'new':
|
||||
# Save this new address in the list of this user's addresses
|
||||
user_address = trans.model.UserAddress( user=user )
|
||||
self.save_widget_field( trans, user_address, index, **kwd )
|
||||
self.save_widget_field( trans, user_address, field_name, **kwd )
|
||||
trans.sa_session.refresh( user )
|
||||
field_value = int( user_address.id )
|
||||
elif input_text_value in [ '', 'none', 'None', None ]:
|
||||
|
||||
@@ -595,26 +595,28 @@ class User( BaseController, UsesFormDefinitions ):
|
||||
# to change the user_info form
|
||||
user_info_form = user_info_forms[0]
|
||||
values = []
|
||||
for index, field in enumerate(user_info_form.fields):
|
||||
if field['type'] == 'AddressField':
|
||||
value = util.restore_text(params.get('field_%i' % index, ''))
|
||||
for index, field in enumerate( user_info_form.fields ):
|
||||
field_type = field[ 'type' ]
|
||||
field_name = field[ 'name' ]
|
||||
if field_type == 'AddressField':
|
||||
value = util.restore_text( params.get( field_name, '' ) )
|
||||
if value == 'new':
|
||||
# save this new address in the list of this user's addresses
|
||||
user_address = trans.app.model.UserAddress( user=user )
|
||||
self.save_widget_field( trans, user_address, index, **kwd )
|
||||
self.save_widget_field( trans, user_address, field_name, **kwd )
|
||||
trans.sa_session.refresh( user )
|
||||
values.append(int(user_address.id))
|
||||
elif value == unicode('none'):
|
||||
values.append('')
|
||||
values.append(int( user_address.id ) )
|
||||
elif value == unicode( 'none' ):
|
||||
values.append( '' )
|
||||
else:
|
||||
values.append(int(value))
|
||||
elif field['type'] == 'CheckboxField':
|
||||
values.append(CheckboxField.is_checked( params.get('field_%i' % index, '') ))
|
||||
values.append( int( value ) )
|
||||
elif field[ 'type' ] == 'CheckboxField':
|
||||
values.append( CheckboxField.is_checked( params.get( field_name, '' ) ) )
|
||||
else:
|
||||
values.append(util.restore_text(params.get('field_%i' % index, '')))
|
||||
values.append( util.restore_text( params.get( field_name, '' ) ) )
|
||||
if new_user or not user.values:
|
||||
# new user or existing
|
||||
form_values = trans.app.model.FormValues(user_info_form, values)
|
||||
form_values = trans.app.model.FormValues( user_info_form, values )
|
||||
trans.sa_session.add( form_values )
|
||||
trans.sa_session.flush()
|
||||
user.values = form_values
|
||||
@@ -719,16 +721,16 @@ class User( BaseController, UsesFormDefinitions ):
|
||||
try:
|
||||
user_info_form = trans.sa_session.query( trans.app.model.FormDefinition ).get(int(selected_user_form_id))
|
||||
except:
|
||||
return user_info_select, None, None
|
||||
return user_info_select, None, []
|
||||
if user:
|
||||
if user.values:
|
||||
widgets = user_info_form.get_widgets(user=user,
|
||||
contents=user.values.content,
|
||||
**kwd)
|
||||
else:
|
||||
widgets = user_info_form.get_widgets(None, contents=[], **kwd)
|
||||
widgets = user_info_form.get_widgets(None, contents={}, **kwd)
|
||||
else:
|
||||
widgets = user_info_form.get_widgets(None, contents=[], **kwd)
|
||||
widgets = user_info_form.get_widgets(None, contents={}, **kwd)
|
||||
return user_info_select, user_info_form, widgets
|
||||
@web.expose
|
||||
def show_info( self, trans, **kwd ):
|
||||
|
||||
Reference in New Issue
Block a user