Ejemplo n.º 1
0
    def put(self, request, *args, **kwargs):
        """
        修改开启、关闭注册状态
        """
        user_id = request.user.user_id
        enterprise_id = request.user.enterprise_id
        admin = enterprise_user_perm_repo.is_admin(user_id=user_id,
                                                   eid=enterprise_id)
        is_regist = request.data.get("is_regist")
        if admin:
            if is_regist is False:
                # 修改全局配置
                platform_config_service.update_config("IS_REGIST", {
                    "enable": False,
                    "value": None
                })

                return Response(general_message(200, "close register", "关闭注册"),
                                status=200)
            else:
                platform_config_service.update_config("IS_REGIST", {
                    "enable": True,
                    "value": None
                })
                return Response(general_message(200, "open register", "开启注册"),
                                status=200)
        else:
            return Response(general_message(400, "no jurisdiction", "没有权限"),
                            status=400)
Ejemplo n.º 2
0
 def update_region_config(self):
     region_data = self.generate_region_config()
     try:
         platform_config_service.get_config_by_key("REGION_SERVICE_API")
         platform_config_service.update_config("REGION_SERVICE_API",
                                               region_data)
     except ConsoleSysConfig.DoesNotExist:
         platform_config_service.add_config("REGION_SERVICE_API",
                                            region_data, 'json', "数据中心配置")
Ejemplo n.º 3
0
 def put(self, request, *args, **kwargs):
     key = request.GET.get("key")
     if not key:
         result = general_message(404, u"no found config key", u"更新失败")
         return Response(result, status=result.get("code", 200))
     value = request.data.get(key, None)
     if not value:
         result = general_message(404, u"no found config value", u"更新失败")
         return Response(result, status=result.get("code", 200))
     key = key.upper()
     if key in platform_config_service.base_cfg_keys + platform_config_service.cfg_keys:
         data = platform_config_service.update_config(key, value)
         try:
             result = general_message(200, u"success", u"更新成功", bean=data)
         except Exception as e:
             logger.debug(e)
             raise ServiceHandleException(msg=u"update enterprise config failed", msg_show=u"更新失败")
     else:
         result = general_message(404, u"no found config key", u"更新失败")
     return Response(result, status=result.get("code", 200))