Commit b4ff40eb045a7f57f207ba4d8be631b9508575f6

Authored by hitier
1 parent 06a8b735

More comments in config files

INSTALL.md
... ... @@ -5,12 +5,14 @@
5 5 - python3
6 6 - sqlite ( pour le développement et les tests unitaires )
7 7 - chrome-driver et chromium ( pour les tests unitaires)
8   -- postgresql ou mariadb (pour la production)
  8 +- postgresql ou mysql/mariadb ( pour la production )
9 9  
10 10 ## Obtenir un répertoire fonctionnel
11 11  
  12 + export GIT_SSL_NO_VERIFY=1
12 13 git clone https://gitlab.irap.omp.eu/PDC-IRAP/pdc-web.git
13 14 cd pdc-web
  15 + git checkout dev # éventuellement travailler avec la branche la plus à jour
14 16  
15 17 ### Installer l'environment python
16 18  
... ... @@ -27,7 +29,7 @@
27 29 cp resources/db_config.py .
28 30 $(EDITOR) db_config.py
29 31  
30   - # Ensuite l'appli elle même (ce fichier est utilisable tel quel)
  32 + # Ensuite l'application elle même (ce fichier est utilisable tel quel)
31 33 cp resources/flaskenv .flaskenv
32 34 $(EDITOR) .flaskenv
33 35  
... ...
resources/db_config.py
  1 +# Here are the databases configuration models for the main database engines:
  2 +# sqlite, mysql, postgresql
  3 +#
  4 +# Edit the one you need, then set proper variable at the end of the file.
  5 +#
  6 +
1 7 SQLITE = {
2   - 'file': '/home/user/tmp/pdc.db'
  8 + 'file': '/path/to/directory/pdc.db'
3 9 }
4 10 sqlite_uri = 'sqlite:///%(file)s' % SQLITE
5 11  
6 12 MYSQL = {
7 13 'user': 'mysql',
8 14 'pw': 'mysql',
9   - 'db': 'pdc_dev',
  15 + 'db': 'pdc_db',
10 16 'host': '127.0.0.1',
11 17 'port': '3306',
12 18 }
13 19 mysql_uri = 'mysql+pymysql://%(user)s:%(pw)s@%(host)s:%(port)s/%(db)s' % MYSQL
14 20  
15 21 POSTGRES = {
16   - 'user': 'aroma-user',
17   - 'pw': 'aroma-pwd',
18   - 'db': 'aroma-db',
  22 + 'user': 'pdc-user',
  23 + 'pw': 'pdc-pwd',
  24 + 'db': 'pdc-db',
19 25 'host': '127.0.0.1',
20 26 'port': '5432',
21 27 }
22 28 postgres_uri = 'postgresql://%(user)s:%(pw)s@%(host)s:%(port)s/%(db)s' % POSTGRES
23 29  
24   -POSTGRESDEV = {
25   - 'user': 'aroma-user',
26   - 'pw': 'aroma-pwd',
27   - 'db': 'aroma-dev-db',
28   - 'host': '127.0.0.1',
29   - 'port': '5433',
30   -}
31   -postgres_dev_uri = 'postgresql://%(user)s:%(pw)s@%(host)s:%(port)s/%(db)s' % POSTGRESDEV
32   -
  30 +# If needed, use other databases depending on the development phase you are on:
  31 +# testing, dev, or production: see below for the proper var to set.
  32 +#
33 33 POSTGRESTEST = {
34   - 'user': 'aroma-user',
35   - 'pw': 'aroma-pwd',
36   - 'db': 'aroma-test-db',
  34 + 'user': 'pdctest-user',
  35 + 'pw': 'pdctest-pwd',
  36 + 'db': 'pdctest-test-db',
37 37 'host': '127.0.0.1',
38 38 'port': '5434',
39 39 }
40 40 postgres_test_uri = 'postgresql://%(user)s:%(pw)s@%(host)s:%(port)s/%(db)s' % POSTGRESTEST
41 41  
42 42 # The lesia mysql agents database
  43 +# It is possible to connect to a lesia like mysql db.
  44 +# set it here
43 45 MYSQL_LESIA = {
44 46 'user': 'mysql',
45 47 'pw': 'mysql',
46   - 'db': 'pdc_dev',
  48 + 'db': 'lesia_db',
47 49 'host': '127.0.0.1',
48 50 'port': '3306',
49 51 }
50 52 mysql_lesia_uri = 'mysql+pymysql://%(user)s:%(pw)s@%(host)s:%(port)s/%(db)s' % MYSQL
51 53  
52   -# Here, set you database uri
53   -# will be imported in ./pdc_config.py
  54 +# To set you databases uri,
  55 +# uncomment the needed lines to fit your specific needs;
  56 +# they will be imported in ./pdc_config.py
  57 +# ( remember to edit the corresponding database setting above )
54 58 #
55   -# sqlalchemy_database_uri = 'sqlite:///:memory:'
56   -# sqlalchemy_database_uri = 'sqlite:///another-app.db'
  59 +
  60 +# The main database for a production site:
  61 +# ( defaults to an sqlite db file )
  62 +#
  63 +# sqlalchemy_database_uri = mysql_uri
  64 +# sqlalchemy_database_uri = sqlite_uri
57 65 # sqlalchemy_database_uri = postgres_uri
58   -# sqlalchemy_testdb_uri = postgres_test_uri
  66 +
  67 +# The development database:
  68 +# ( defaults to an sqlite db file )
  69 +#
59 70 # sqlalchemy_devdb_uri = postgres_dev_uri
60   -sqlalchemy_devdb_uri = 'sqlite:///another-app.db'
  71 +
  72 +# The unit tests database:
  73 +# ( defaults to in memory sqlite db: 'sqlite:///:memory:' )
  74 +#
  75 +# sqlalchemy_testdb_uri = postgres_test_uri
... ...
resources/flaskenv
  1 +# flask command configuration file.
  2 +#
  3 +# cf https://flask.palletsprojects.com/en/1.1.x/cli/
  4 +# and https://flask.palletsprojects.com/en/1.1.x/config/
  5 +#
  6 +
  7 +# Default set to 'production',
  8 +# but 'development' value adds debuging facities.
  9 +#
1 10 FLASK_ENV=development
  11 +
  12 +# Is set to the python application wrapper
  13 +# you shouldnt edit.
  14 +#
2 15 FLASK_APP=pdc_web
... ...
resources/pdc_config.py
... ... @@ -20,26 +20,28 @@ class Config(object):
20 20 # Please change the following to fit you own site parameters
21 21 #
22 22 PDC_APP_NAME = 'Plan de Charge'
23   - PDC_SITE_NAME = 'NO_SITE' # choose among IRAP, PUBLIC, ...
24   - PDC_SITE_CLASS = 'public-icon' # choose among admin-icon, public-icon
25   - PDC_LOGS_LEVEL = 'DEBUG' # choose within DEBUG, INFO, WARN, ERROR ( more levels in logging module )
  23 + PDC_SITE_NAME = 'NO_SITE' # choose among DEV, IRAP, LESIA, LAM ... will display on page's title
  24 + PDC_SITE_CLASS = 'public-icon' # choose among admin-icon, public-icon, dev-icon, see more in app/static/style.css
  25 + PDC_LOGS_LEVEL = 'ERROR' # choose within DEBUG, INFO, WARN, ERROR ( more in the python logging module )
26 26 PDC_LOGS_DIR = os.path.join(root_dir, 'logs')
27 27 PDC_LOGS_FILE = os.path.join(PDC_LOGS_DIR, 'pdc.log')
28 28  
29 29 # Uncomment for role access control
  30 + #
30 31 # if True, will disable any role control on routes
31 32 # note that this doesnt disable the @login_required
32 33 #
33 34 # ROLE_DISABLED = False
34 35  
35 36 # Uncomment for site access control
  37 + #
36 38 # if True, will force login access on any site page
37   - # note that this doesnt disable the @login_required
38 39 #
39 40 # SITE_LOGIN = False
40 41  
41 42 #
42 43 # No need to Edit below
  44 + # ( but keep reading )
43 45 #
44 46  
45 47 # You can force logging to stdout in production environment
... ... @@ -55,7 +57,7 @@ class Config(object):
55 57 SQLALCHEMY_DATABASE_URI = sqlalchemy_database_uri
56 58 except NameError:
57 59 SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
58   - 'sqlite:///' + os.path.join(root_dir, 'pdc_app.db')
  60 + 'sqlite:///' + os.path.join(root_dir, 'pdc.db')
59 61  
60 62 try:
61 63 LESIA_AGENTS_DB_URI = mysql_lesia_uri
... ... @@ -67,35 +69,43 @@ class Config(object):
67 69 VERSION = version_file.read().strip()
68 70  
69 71  
  72 +# Production configuration
  73 +#
70 74 class ProdConfig(Config):
71 75 TESTING = False
72 76 DEBUG = False
73 77  
74 78  
  79 +# Development configuration
  80 +#
75 81 class DevConfig(Config):
76 82 DEBUG = True
  83 +
77 84 # Trying to set specific db uri from ./db_config.py
78 85 try:
79 86 SQLALCHEMY_DATABASE_URI = sqlalchemy_devdb_uri
80 87 except NameError:
81 88 SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
82   - 'sqlite:///' + os.path.join(root_dir, 'pdc_app_dev.db')
  89 + 'sqlite:///' + os.path.join(root_dir, 'pdc_dev.db')
83 90 # ignores @login_required decorator
84 91 LOGIN_DISABLED = True
85 92 # ignores @role_required decorator
86 93 ROLE_DISABLED = True
87 94  
88 95  
  96 +# Testing configuration
  97 +#
89 98 class TestConfig(Config):
90 99 TESTING = True
91 100 DEBUG = True
92 101 PDC_LOGS_LEVEL = 'ERROR' # choose within DEBUG, INFO, WARN, ERROR ( more levels in logging module )
  102 +
93 103 # Trying to set specific db uri from ./db_config.py
94 104 try:
95 105 SQLALCHEMY_DATABASE_URI = sqlalchemy_testdb_uri
96 106 except NameError:
97 107 SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
98   - 'sqlite:///' + os.path.join(root_dir, 'pdc_app_test.db')
  108 + 'sqlite:///' + os.path.join(root_dir, 'pdc_test.db')
99 109 # ignores @login_required decorator
100 110 LOGIN_DISABLED = True
101 111 # ignores @role_required decorator
... ...