コード例 #1
0
ファイル: ctrl_model.py プロジェクト: lsn1183/web_project
 def get_model_ref_model(self, data_json):
     from app.ctrl.ctrl_project import CtrlProject
     from app.ctrl.ctrl_group import CtrlGroup
     proj_id = data_json.get('proj_id')
     accessToken = data_json.get('accessToken')
     username = data_json.get('username')
     try:
         if username in ("Admin", "Test_PMO", "Test_PL", "Test_GL"):
             model_list = CtrlProject().get_leaf_model(proj_id)
         else:
             project_root = CtrlGroup().get_project_root(
                 accessToken, proj_id)
             if not project_root:
                 return None, "您不在该项目体制中!"
             pmo = project_root.get('pmo')
             pl_username = project_root.get('username')
             if username == pmo.get('userName'):
                 model_list = CtrlProject().get_leaf_model(proj_id)
             elif pl_username == username:
                 model_list = CtrlProject().get_leaf_model(proj_id)
             else:
                 group_members = project_root.get('group_members')
                 model_list = self.get_gl_model_list(
                     group_members, username)
         data_list = []
         for model in model_list:
             model_id = model.get('model_id')
             model_ref = self.get_model_ref(proj_id, model_id)
             model['model_ref'] = model_ref
             model['model_list'] = []  # 前端要求加的
             data_list.append(model)
         return data_list, None
     except Exception as e:
         current_app.logger.error('%s' % str(e))
         return None, "服务异常!请联系管理员!"
コード例 #2
0
ファイル: ctrl_model.py プロジェクト: lsn1183/web_project
 def get_authors(self, proj_id, model_id):
     q = (
         db.session.query(GroupModel).
         filter(  # GroupModel.proj_id == proj_id, TODO@hcz:暂时没有
             GroupModel.model_id == model_id).order_by(GroupModel.gid))
     from app.ctrl.ctrl_group import CtrlGroup
     group = CtrlGroup()
     group_members = []
     for group_model in q:
         group_members += group.get_group_members(group_model.group_id)
     return group_members
コード例 #3
0
 def get(self, group_id=None):
     """
     获取组成员信息
     :param group_id:
     :return:
     """
     result = {"result": "NG"}
     ctrl_obj = CtrlGroup()
     content = ctrl_obj.get_group_members(group_id)
     if content:
         result["result"] = "OK"
         result["content"] = content
     return result
コード例 #4
0
 def get(self, group_name=None):
     """
     获取组的信息
     :param group_name:
     :return:
     """
     result = {"result": "NG"}
     ctrl_obj = CtrlGroup()
     content = ctrl_obj.get_groups(group_name)
     if content:
         result["result"] = "OK"
         result["content"] = content
     return result
コード例 #5
0
 def post(self):
     """
     添加组成员
     :return:
     """
     json_data = request.get_json(force=True)
     ctrl_obj = CtrlGroup()
     result = {'result': 'NG', 'error': ''}
     try:
         ctrl_obj.add_group_members(json_data)
         result['result'] = "OK"
     except Exception as e:
         current_app.logger.error('%s' % str(e))
         result['error'] = str(e)
     return result
コード例 #6
0
 def delete(self, group_id):
     """
     删除组
     :param group_id:
     :return:
     """
     ctrl_obj = CtrlGroup()
     result = {'result': 'NG', 'error': ''}
     try:
         ctrl_obj.delete_group(group_id)
         result['result'] = "OK"
     except Exception as e:
         current_app.logger.error('%s' % str(e))
         result['error'] = str(e)
     return result
コード例 #7
0
 def put(self):
     """
     编辑组成员角色
     :return:
     """
     json_data = request.get_json(force=True)
     ctrl_obj = CtrlGroup()
     result = {'result': 'NG', 'error': ''}
     try:
         ctrl_obj.update_member_role(json_data)
         result['result'] = "OK"
     except Exception as e:
         current_app.logger.error('%s' % str(e))
         result['error'] = str(e)
     return result
コード例 #8
0
ファイル: ctrl_model.py プロジェクト: lsn1183/web_project
 def get_gl_model_list(self, group_members, username):
     from app.ctrl.ctrl_group import CtrlGroup
     model_list = []
     for group in group_members:
         if username == group.get('username') and group.get(
                 'user_role') == 'GL':
             model_list += CtrlGroup().get_model_by_group(
                 group.get('group_name'))
     return model_list
コード例 #9
0
 def post(self):
     result = {"result": "NG"}
     from app.ctrl.ctrl_group import CtrlGroup
     data_json = request.get_json(force=True)
     proj_id = data_json.get('proj_id')
     model_id = data_json.get('model_id')
     accessToken = data_json.get('accessToken')
     group_message, model_name = CtrlGroup().get_cactus_group_mesage(
         proj_id, model_id, accessToken)
     if group_message:
         result["result"] = "OK"
         result['content'] = group_message
         result['model_name'] = model_name
     return result
コード例 #10
0
 def post(self):
     """
     从cactus上拿项目的组信息
     :return:
     """
     result = {"result": "NG"}
     from app.ctrl.ctrl_group import CtrlGroup
     data_json = request.get_json(force=True)
     accessToken = data_json.get('accessToken')
     proj_id = data_json.get('proj_id')
     group_list = CtrlGroup().get_project_group(accessToken, proj_id)
     if group_list:
         result["result"] = "OK"
         result['content'] = group_list
     return result
コード例 #11
0
 def get_role_by_cactus(self, data_json):
     """
     从cactus项目体制中获取用户角色
     :param proj_id:
     :param accessToken:
     :param model_id:
     :return:
     """
     try:
         role_list = []
         proj_id = data_json.get('proj_id')
         accessToken = data_json.get('accessToken')
         model_id = data_json.get('model_id')
         username = data_json.get('username')
         user = self.get_user_by_name(username)
         roles = CtrlRole().get_roles_by_user(user.user_id)
         if user.user_type == "TEST" or "Admin" in roles:
             perm_list = self.get_user_permission(user.user_id)
             return perm_list, None
         group_list = []
         if model_id:
             group_list = self.get_group_by_model(proj_id, model_id)
             if not group_list:
                 return role_list, "该模块还没分配组!"
         from app.ctrl.ctrl_group import CtrlGroup
         project_root = CtrlGroup().get_project_root(accessToken, proj_id)
         if not project_root:
             return [], None
         if project_root:
             pmo = project_root.get('pmo')
             if username == pmo.get('userName'):
                 role_list.append('PMO')
             pl_username = project_root.get('username')
             if pl_username == username:
                 role_list.append(project_root.get('user_role'))
             group_members = project_root.get('group_members')
             if group_members:
                 for group in group_members:
                     if username == group.get('username'):
                         if group.get('group_name') in group_list:
                             role_list.append(group.get('user_role'))
         if role_list:
             from app.ctrl.ctrl_permission import CtrlPermission
             perm_list = CtrlPermission().get_perm_by_role(role_list)
         else:
             if model_id:
                 perm_list = self.user_in_model_rel(proj_id, model_id, username, project_root)
             else:
                 perm_list = []
         return perm_list, None
     except Exception as e:
         db.session.rollback()
         current_app.logger.error('%s' % e)
         error = "服务异常!请联系管理员!"
         return None, error