def regions(cls): configs = custom_settings.configs() # api_conf = custom_settings.REGION_SERVICE_API api_conf = configs.get("REGION_SERVICE_API", None) # 自定义配置不存在时访问settings文件 if not api_conf: return settings.REGIONS else: region_list = [] for conf in api_conf: region_map = {} region_map["name"] = conf["region_name"] region_map["label"] = conf["region_alias"] region_map["enable"] = conf.get("enable", True) region_list.append(region_map) return region_list
def regions(cls): configs = custom_settings.configs() # api_conf = custom_settings.REGION_SERVICE_API api_conf = configs.get("REGION_SERVICE_API", None) # 自定义配置不存在时访问settings文件 if not api_conf: regions = region_repo.get_all_regions() region_list = [{ "name": r.region_name, "label": r.region_alias, "enable": bool(r.status == "1") } for r in regions] return region_list else: region_list = [] for conf in api_conf: region_map = dict() region_map["name"] = conf["region_name"] region_map["label"] = conf["region_alias"] region_map["enable"] = conf.get("enable", True) region_list.append(region_map) return region_list
def __get_oss_config(self): configs = custom_settings.configs() oss_conf = configs.get("OSS_CONFIG", None) if not oss_conf: return settings.OSS_CONFIG return oss_conf
def get_context(self): context = super(BaseView, self).get_context() context['CUSTOM_CONFIG'] = custom_config.configs() return context