def apply(self, query, value): if g.user.is_admin(): return query.filter(self.model.type == value).order_by( self.model.id.desc()) join_projects_id = security_manager.get_join_projects_id(db.session) return query.filter(self.model.id.in_(join_projects_id)).filter( self.model.type == value).order_by(self.model.id.desc())
def apply(self, query, func): if g.user.is_admin(): return query join_projects_id = security_manager.get_join_projects_id(db.session) # public_project_id = # logging.info(join_projects_id) return query.filter(self.model.project_id.in_(join_projects_id))
def apply(self, query, func): user_roles = [ role.name.lower() for role in list(self.get_user_roles()) ] if "admin" in user_roles: return query.order_by(self.model.id.desc()) join_projects_id = security_manager.get_join_projects_id(db.session) # public_project_id = # logging.info(join_projects_id) return query.filter( or_(self.model.project_id.in_(join_projects_id), # self.model.project.name.in_(['public']) )).order_by(self.model.id.desc())
def wraps(*args, **kwargs): service_pipeline_id = int(kwargs.get('service_pipeline_id', '0')) if not service_pipeline_id: response = make_response("service_pipeline_id not exist") response.status_code = 404 return response user_roles = [role.name.lower() for role in g.user.roles] if "admin" in user_roles: return user_fun(*args, **kwargs) join_projects_id = security_manager.get_join_projects_id( db.session) service_pipeline = db.session.query(Service_Pipeline).filter_by( id=service_pipeline_id).first() if service_pipeline.project.id in join_projects_id: return user_fun(*args, **kwargs) response = make_response("no perms to run pipeline %s" % service_pipeline_id) response.status_code = 403 return response