forked from ISPsystem/isp-maintenance
Edit: models.py
This commit is contained in:
parent
d20514a4a5
commit
10059f6932
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
12
.idea/isp-maintenance.iml
Normal file
12
.idea/isp-maintenance.iml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="jdk" jdkName="Poetry (isp-maintenance) (3)" jdkType="Python SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
<component name="PyDocumentationSettings">
|
||||||
|
<option name="format" value="PLAIN" />
|
||||||
|
<option name="myDocStringFormat" value="Plain" />
|
||||||
|
</component>
|
||||||
|
</module>
|
7
.idea/misc.xml
Normal file
7
.idea/misc.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Black">
|
||||||
|
<option name="sdkName" value="Poetry (isp-maintenance) (3)" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Poetry (isp-maintenance) (3)" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/isp-maintenance.iml" filepath="$PROJECT_DIR$/.idea/isp-maintenance.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,6 @@
|
|||||||
|
class UnknownField(object):
|
||||||
|
def __init__(self, *_, **__): pass
|
||||||
|
|
||||||
|
class BaseModel(Model):
|
||||||
|
class Meta:
|
||||||
|
database = db
|
@ -1,43 +1,5 @@
|
|||||||
import os
|
from peewee import Model, MySQLDatabase, CharField, IntegerField
|
||||||
import json
|
|
||||||
|
|
||||||
from peewee import Model, MySQLDatabase, CharField
|
|
||||||
|
|
||||||
CLIENT_HOST = os.environ.get("CLIENT_HOST", "replace_to_client_host")
|
|
||||||
PLATFORM = os.environ.get("PLATFORM", "vm") # or dci
|
|
||||||
|
|
||||||
DB_ENGINE = os.environ.get("DB_ENGINE", "mysql")
|
|
||||||
DB_HOST = os.environ.get("DB_HOST", "mysql")
|
|
||||||
DB_PORT = os.environ.get("DB_PORT", 3306)
|
|
||||||
DB_USER = os.environ.get("DB_USER", "root")
|
|
||||||
DB_PASSWORD = os.environ.get("DB_PASSWORD", None) # not secure!!!
|
|
||||||
DB_NAME = os.environ.get("DB_NAME", "isp") # or auth for dci
|
|
||||||
|
|
||||||
if DB_PASSWORD is None:
|
|
||||||
with open('config.json', 'r') as f:
|
|
||||||
platform_config = json.load(f)
|
|
||||||
DB_PASSWORD = platform_config.get("MysqlRootPassword")
|
|
||||||
|
|
||||||
|
|
||||||
# Подключение к базе данных
|
|
||||||
db = MySQLDatabase(
|
|
||||||
DB_NAME, **{
|
|
||||||
'charset': 'utf8',
|
|
||||||
'sql_mode': 'PIPES_AS_CONCAT',
|
|
||||||
'use_unicode': True,
|
|
||||||
'host': DB_HOST,
|
|
||||||
'port': DB_PORT,
|
|
||||||
'user': DB_USER,
|
|
||||||
'password': DB_PASSWORD
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
class UnknownField(object):
|
|
||||||
def __init__(self, *_, **__): pass
|
|
||||||
|
|
||||||
class BaseModel(Model):
|
|
||||||
class Meta:
|
|
||||||
database = db
|
|
||||||
|
|
||||||
class AlertSetting(BaseModel):
|
class AlertSetting(BaseModel):
|
||||||
channel = UnknownField(null=True) # json
|
channel = UnknownField(null=True) # json
|
||||||
|
Loading…
Reference in New Issue
Block a user