Esempio n. 1
0
 def get(self, request, *args, **kwargs):
     try:
         code = 200
         status = role_perm_repo.initialize_permission_settings()
         data = platform_config_service.initialization_or_get_config
         result = general_message(code, "query success", u"Logo获取成功", bean=data, initialize_info=status)
         return Response(result, status=code)
     except Exception as e:
         logger.exception(e)
         result = error_message(e.message)
     return Response(result)
Esempio n. 2
0
    def get(self, request, *args, **kwargs):
        """
        登录页面获取云帮Logo、标题、github、gitlab配置信息(不要Authorization头)
        ---
        """
        try:
            # 判断是否已经初始化权限默认数据,没有则初始化
            status = role_perm_repo.initialize_permission_settings()
            code = 200
            data = dict()
            logo = config_service.get_image()
            host_name = request.get_host()
            build_absolute_uri = request.build_absolute_uri()
            scheme = "http"
            if build_absolute_uri.startswith("https"):
                scheme = "https"
            data["logo"] = "{0}".format(str(logo))
            # 判断是否为公有云
            if settings.MODULES.get('SSO_LOGIN'):
                data["url"] = "https://sso.goodrain.com/#/login/"
                data["is_public"] = True
            else:
                data["url"] = "{0}://{1}/index#/user/login".format(scheme, request.get_host())
                data["is_public"] = False

            title = config_service.get_config_by_key("TITLE")
            if not title:
                config = config_service.add_config("TITLE", "好雨云帮", "string", "云帮title")
                title = config.value
            data["title"] = title
            if settings.MODULES.get('SSO_LOGIN'):
                data["is_user_register"] = True
            else:
                users = user_repo.get_all_users()
                if users:
                    data["is_user_register"] = True
                else:
                    data["is_user_register"] = False

            github_config = config_service.get_github_config()
            data["github_config"] = github_config

            gitlab_config = config_service.get_gitlab_config()
            data["gitlab_config"] = gitlab_config


            result = general_message(code, "query success", "Logo获取成功", bean=data, initialize_info=status)
            return Response(result, status=code)
        except Exception as e:
            logger.exception(e)
            result = error_message(e.message)
        return Response(result)
Esempio n. 3
0
    def get(self, request, *args, **kwargs):
        """
        登录页面获取云帮Logo、标题、github、gitlab配置信息(不要Authorization头)
        ---
        """
        try:
            # 判断是否已经初始化权限默认数据,没有则初始化
            status = role_perm_repo.initialize_permission_settings()
            code = 200
            data = dict()
            logo = config_service.get_image()
            build_absolute_uri = request.build_absolute_uri()
            scheme = "http"

            if build_absolute_uri.startswith("https"):
                scheme = "https"
            data["logo"] = "{0}".format(str(logo))
            # 判断是否为公有云
            if settings.MODULES.get('SSO_LOGIN'):
                data["url"] = os.getenv(
                    "SSO_BASE_URL", "https://sso.goodrain.com") + "/#/login/"
                data["is_public"] = True
            else:
                data["url"] = "{0}://{1}/index#/user/login".format(
                    scheme, request.get_host())
                data["is_public"] = False

            title = config_service.get_config_by_key("TITLE")
            if not title:
                config = config_service.add_config(
                    "TITLE", "Rainbond-企业云应用操作系统,开发、交付云解决方案", "string",
                    "云帮title")
                title = config.value
            data["title"] = title
            if settings.MODULES.get('SSO_LOGIN'):
                data["is_user_register"] = True
            else:
                users = user_repo.get_all_users()
                if users:
                    data["is_user_register"] = True
                else:
                    data["is_user_register"] = False

            is_regist = config_service.get_config_by_key("REGISTER_STATUS")
            if not is_regist:
                is_regist = config_service.add_config(key="REGISTER_STATUS",
                                                      default_value="yes",
                                                      type="string",
                                                      desc="开启/关闭注册").value
            if is_regist == "yes":
                data["is_regist"] = True
            else:
                data["is_regist"] = False
            # if register_config[0].value != "yes":
            #     data["is_regist"] = False
            # else:
            #     data["is_regist"] = True

            github_config = config_service.get_github_config()
            data["github_config"] = github_config

            gitlab_config = config_service.get_gitlab_config()
            data["gitlab_config"] = gitlab_config

            data["eid"] = None
            enterprise = enterprise_repo.get_enterprise_first()
            if enterprise:
                data["eid"] = enterprise.enterprise_id
                data["enterprise_name"] = enterprise.enterprise_alias
                market_token = market_sycn_service.get_enterprise_access_token(
                    enterprise.enterprise_id, "market")
                if market_token:
                    data["market_url"] = market_token.access_url
                else:
                    data["market_url"] = os.getenv(
                        'GOODRAIN_APP_API', settings.APP_SERVICE_API["url"])
            data["version"] = os.getenv("RELEASE_DESC", "public-cloud")
            result = general_message(code,
                                     "query success",
                                     "Logo获取成功",
                                     bean=data,
                                     initialize_info=status)
            return Response(result, status=code)
        except Exception as e:
            logger.exception(e)
            result = error_message(e.message)
        return Response(result)
Esempio n. 4
0
    def get(self, request, *args, **kwargs):
        try:
            code = 200
            status = role_perm_repo.initialize_permission_settings()
            data = config_service.initialization_or_get_config()
            base_data = config_service.initialization_or_get_base_config()
            data.update(base_data)
            logo = config_service.get_image()
            data["logo"] = "{0}".format(str(logo))
            title = config_service.get_config_by_key("TITLE")
            if not title:
                config = config_service.add_config(
                    "TITLE",
                    "Rainbond-企业云应用操作系统,开发、交付云解决方案",
                    "string",
                    desc="云帮title")
                title = config.value
            else:
                title = title.value
            data["title"] = title
            data["version"] = os.getenv("RELEASE_DESC", "public-cloud")
            result = general_message(code,
                                     "query success",
                                     u"Logo获取成功",
                                     bean=data,
                                     initialize_info=status)
            data["eid"] = None
            enterprise = enterprise_repo.get_enterprise_first()
            if enterprise:
                data["eid"] = enterprise.enterprise_id
                data["enterprise_name"] = enterprise.enterprise_alias

            build_absolute_uri = request.build_absolute_uri()
            scheme = "http"
            if build_absolute_uri.startswith("https"):
                scheme = "https"
            if settings.MODULES.get('SSO_LOGIN'):
                data["url"] = os.getenv(
                    "SSO_BASE_URL", "https://sso.goodrain.com") + "/#/login/"
                data["is_public"] = True
            else:
                data["url"] = "{0}://{1}/index#/user/login".format(
                    scheme, request.get_host())
                data["is_public"] = False

            if settings.MODULES.get('SSO_LOGIN'):
                data["is_user_register"] = True
            else:
                users = user_repo.get_all_users()
                if users:
                    data["is_user_register"] = True
                else:
                    data["is_user_register"] = False

            data["eid"] = None
            enterprise = enterprise_repo.get_enterprise_first()
            if enterprise:
                data["eid"] = enterprise.enterprise_id
                data["enterprise_name"] = enterprise.enterprise_alias
                market_token = market_sycn_service.get_enterprise_access_token(
                    enterprise.enterprise_id, "market")
                if market_token:
                    data["market_url"] = market_token.access_url
                else:
                    data["market_url"] = os.getenv(
                        'GOODRAIN_APP_API', settings.APP_SERVICE_API["url"])
            data["version"] = os.getenv("RELEASE_DESC", "public-cloud")
            return Response(result, status=code)
        except Exception as e:
            logger.exception(e)
            result = error_message(e.message)
        return Response(result)