def add_config_without_reload(self, key, default_value, type, desc=""):
     if not ConsoleSysConfig.objects.filter(key=key).exists():
         create_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
         config = ConsoleSysConfig.objects.create(key=key,
                                                  type=type,
                                                  value=default_value,
                                                  desc=desc,
                                                  create_time=create_time)
         return config
     else:
         raise ConfigExistError("配置{}已存在".format(key))
Example #2
0
 def add_config(self, key, default_value, type, enable=True, desc=""):
     if not ConsoleSysConfig.objects.filter(
             key=key, enterprise_id=self.enterprise_id).exists():
         create_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
         config = ConsoleSysConfig.objects.create(
             key=key,
             type=type,
             value=default_value,
             desc=desc,
             create_time=create_time,
             enable=enable,
             enterprise_id=self.enterprise_id)
         custom_settings.reload()
         return config
     else:
         raise ConfigExistError("配置{}已存在".format(key))