示例#1
0
文件: users.py 项目: msauria/galaxy
 def create(self, trans: GalaxyWebTransaction, payload: dict, **kwd):
     """
     POST /api/users
     Creates a new Galaxy user.
     """
     if not trans.app.config.allow_user_creation and not trans.user_is_admin:
         raise exceptions.ConfigDoesNotAllowException(
             'User creation is not allowed in this Galaxy instance')
     if trans.app.config.use_remote_user and trans.user_is_admin:
         user = trans.get_or_create_remote_user(
             remote_user_email=payload['remote_user_email'])
     elif trans.user_is_admin:
         username = payload['username']
         email = payload['email']
         password = payload['password']
         message = "\n".join((validate_email(trans, email),
                              validate_password(trans, password, password),
                              validate_publicname(trans,
                                                  username))).rstrip()
         if message:
             raise exceptions.RequestParameterInvalidException(message)
         else:
             user = self.user_manager.create(email=email,
                                             username=username,
                                             password=password)
     else:
         raise exceptions.NotImplemented()
     item = user.to_dict(view='element',
                         value_mapper={
                             'id': trans.security.encode_id,
                             'total_disk_usage': float
                         })
     return item
示例#2
0
 def _patch_library_dataset(self, trans: GalaxyWebTransaction, v,
                            target_history):
     if isinstance(v, dict) and 'id' in v and v.get('src') == 'ldda':
         ldda = trans.sa_session.query(
             trans.app.model.LibraryDatasetDatasetAssociation).get(
                 self.decode_id(v['id']))
         if trans.user_is_admin or trans.app.security_agent.can_access_dataset(
                 trans.get_current_user_roles(), ldda.dataset):
             return ldda.to_history_dataset_association(target_history,
                                                        add_to_history=True)