Пример #1
0
 def __get_populated_request_type_widgets(self, trans, **kwd):
     request_form_definitions = self.get_all_forms(
         trans,
         filter=dict(deleted=False),
         form_type=trans.model.FormDefinition.types.REQUEST)
     sample_form_definitions = self.get_all_forms(
         trans,
         filter=dict(deleted=False),
         form_type=trans.model.FormDefinition.types.SAMPLE)
     if not request_form_definitions or not sample_form_definitions:
         return [], []
     params = util.Params(kwd)
     request_form_id = params.get('request_form_id', 'none')
     sample_form_id = params.get('sample_form_id', 'none')
     request_form_id_select_field = build_select_field(
         trans,
         objs=request_form_definitions,
         label_attr='name',
         select_field_name='request_form_id',
         selected_value=request_form_id,
         refresh_on_change=False)
     sample_form_id_select_field = build_select_field(
         trans,
         objs=sample_form_definitions,
         label_attr='name',
         select_field_name='sample_form_id',
         selected_value=sample_form_id,
         refresh_on_change=False)
     rt_info_widgets = [
         dict(label='Name',
              widget=TextField('name', 40,
                               util.restore_text(params.get('name', '')))),
         dict(label='Description',
              widget=TextField('desc', 40,
                               util.restore_text(params.get('desc', '')))),
         dict(label='Request form', widget=request_form_id_select_field),
         dict(label='Sample form', widget=sample_form_id_select_field)
     ]
     # Unsaved sample states being defined for this request type
     rt_states = []
     i = 0
     while True:
         if 'state_name_%i' % i in kwd:
             rt_states.append(
                 (util.restore_text(params.get('state_name_%i' % i, '')),
                  util.restore_text(params.get('state_desc_%i' % i, ''))))
             i += 1
         else:
             break
     return rt_info_widgets, rt_states
Пример #2
0
 def __build_sample_id_select_field(self, trans, request, selected_value):
     return build_select_field(trans,
                               request.samples,
                               'name',
                               'sample_id',
                               selected_value=selected_value,
                               refresh_on_change=False)
Пример #3
0
 def __get_populated_request_type_widgets(self, trans, **kwd):
     request_form_definitions = self.get_all_forms(trans,
                                                   filter=dict(deleted=False),
                                                   form_type=trans.model.FormDefinition.types.REQUEST)
     sample_form_definitions = self.get_all_forms(trans,
                                                  filter=dict(deleted=False),
                                                  form_type=trans.model.FormDefinition.types.SAMPLE)
     if not request_form_definitions or not sample_form_definitions:
         return [], []
     params = util.Params(kwd)
     request_form_id = params.get('request_form_id', 'none')
     sample_form_id = params.get('sample_form_id', 'none')
     request_form_id_select_field = build_select_field(trans,
                                                       objs=request_form_definitions,
                                                       label_attr='name',
                                                       select_field_name='request_form_id',
                                                       selected_value=request_form_id,
                                                       refresh_on_change=False)
     sample_form_id_select_field = build_select_field(trans,
                                                      objs=sample_form_definitions,
                                                      label_attr='name',
                                                      select_field_name='sample_form_id',
                                                      selected_value=sample_form_id,
                                                      refresh_on_change=False)
     rt_info_widgets = [dict(label='Name',
                             widget=TextField('name', 40, util.restore_text(params.get('name', '')))),
                        dict(label='Description',
                             widget=TextField('desc', 40, util.restore_text(params.get('desc', '')))),
                        dict(label='Request form',
                             widget=request_form_id_select_field),
                        dict(label='Sample form',
                             widget=sample_form_id_select_field)]
     # Unsaved sample states being defined for this request type
     rt_states = []
     i = 0
     while True:
         if 'state_name_%i' % i in kwd:
             rt_states.append((util.restore_text(params.get('state_name_%i' % i, '')),
                               util.restore_text(params.get('state_desc_%i' % i, ''))))
             i += 1
         else:
             break
     return rt_info_widgets, rt_states
def build_allow_push_select_field( trans, current_push_list, selected_value='none' ):
    options = []
    for user in trans.sa_session.query( trans.model.User ):
        if user.username not in current_push_list:
            options.append( user )
    return build_select_field( trans,
                               objs=options,
                               label_attr='username',
                               select_field_name='allow_push',
                               selected_value=selected_value,
                               refresh_on_change=False,
                               multiple=True )
Пример #5
0
def build_allow_push_select_field( trans, current_push_list, selected_value='none' ):
    options = []
    for user in trans.sa_session.query( trans.model.User ):
        if user.username not in current_push_list:
            options.append( user )
    return build_select_field( trans,
                               objs=options,
                               label_attr='username',
                               select_field_name='allow_push',
                               selected_value=selected_value,
                               refresh_on_change=False,
                               multiple=True )
Пример #6
0
def build_rename_datasets_for_sample_select_field( trans, sample_dataset, selected_value='none' ):
    options = []
    for option_index, option in enumerate( sample_dataset.file_path.split( os.sep )[ :-1 ] ):
        option = option.strip()
        if option:
            options.append( option )
    return build_select_field( trans,
                               objs=options,
                               label_attr='self',
                               select_field_name='rename_datasets_for_sample_%s' % trans.security.encode_id( sample_dataset.id ),
                               selected_value=selected_value,
                               refresh_on_change=False )
Пример #7
0
def build_rename_datasets_for_sample_select_field( trans, sample_dataset, selected_value='none' ):
    options = []
    for option_index, option in enumerate( sample_dataset.file_path.split( os.sep )[ :-1 ] ):
        option = option.strip()
        if option:
            options.append( option )
    return build_select_field( trans,
                               objs=options,
                               label_attr='self',
                               select_field_name='rename_datasets_for_sample_%s' % trans.security.encode_id( sample_dataset.id ),
                               selected_value=selected_value,
                               refresh_on_change=False )
Пример #8
0
 def __build_external_service_select_field(self, trans, select_field_name, external_service=None):
     if external_service:
         selected_value = trans.security.encode_id(external_service.id)
     else:
         selected_value = 'none'
     all_external_services = trans.sa_session.query(trans.model.ExternalService).filter(trans.model.ExternalService.table.c.deleted == false()).all()
     for e in all_external_services:
         external_service_type = e.get_external_service_type(trans)
         e.label = '%s - %s' % (e.name, external_service_type.name)
     return build_select_field(trans,
                               objs=all_external_services,
                               label_attr='label',
                               select_field_name=select_field_name,
                               selected_value=selected_value,
                               refresh_on_change=False)
Пример #9
0
 def __build_external_service_select_field( self, trans, select_field_name, external_service=None ):
     if external_service:
         selected_value = trans.security.encode_id( external_service.id )
     else:
         selected_value = 'none'
     all_external_services = trans.sa_session.query( trans.model.ExternalService ).filter( trans.model.ExternalService.table.c.deleted == false() ).all()
     for e in all_external_services:
         external_service_type = e.get_external_service_type( trans )
         e.label = '%s - %s' % ( e.name, external_service_type.name )
     return build_select_field( trans,
                                objs=all_external_services,
                                label_attr='label',
                                select_field_name=select_field_name,
                                selected_value=selected_value,
                                refresh_on_change=False )
Пример #10
0
 def __build_sample_id_select_field( self, trans, request, selected_value ):
     return build_select_field( trans, request.samples, 'name', 'sample_id', selected_value=selected_value, refresh_on_change=False )