mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-18 02:44:51 +03:00
🔧 updated post_gen_hook
and .envs
This commit is contained in:
parent
00604b6f50
commit
1e741e9bbf
|
@ -257,7 +257,7 @@ def set_database_user(file_path: str, value: str, database_engine: str):
|
|||
def set_database_password(file_path: str, database_engine: str, value: str = None):
|
||||
database_password = set_flag(
|
||||
file_path,
|
||||
f"!!!SET {database_engine.upper()}_USER!!!",
|
||||
f"!!!SET {database_engine.upper()}_PASSWORD!!!",
|
||||
value=value,
|
||||
length=64,
|
||||
using_digits=True,
|
||||
|
@ -266,6 +266,18 @@ def set_database_password(file_path: str, database_engine: str, value: str = Non
|
|||
return database_password
|
||||
|
||||
|
||||
def set_mysql_root_password(file_path: str, database_engine: str, value: str = None):
|
||||
database_root_password = set_flag(
|
||||
file_path,
|
||||
f"!!!SET {database_engine.upper()}_ROOT_PASSWORD!!!",
|
||||
value=value,
|
||||
length=74,
|
||||
using_digits=True,
|
||||
using_ascii_letters=True,
|
||||
)
|
||||
return database_root_password
|
||||
|
||||
|
||||
def get_database_env_path(env: str, database_engine: str):
|
||||
local_postgres_envs_path = os.path.join(".envs", ".local", ".postgres")
|
||||
production_postgres_envs_path = os.path.join(".envs", ".production", ".postgres")
|
||||
|
@ -345,6 +357,19 @@ def set_flags_in_envs(database_user, celery_flower_user, debug=False):
|
|||
value=DEBUG_VALUE if debug else None,
|
||||
)
|
||||
|
||||
if selected_database == "mysql":
|
||||
set_mysql_root_password(
|
||||
get_database_env_path(env="local", database_engine=selected_database),
|
||||
database_engine=selected_database,
|
||||
value=DEBUG_VALUE if debug else None,
|
||||
)
|
||||
|
||||
set_mysql_root_password(
|
||||
get_database_env_path(env="prod", database_engine=selected_database),
|
||||
database_engine=selected_database,
|
||||
value=DEBUG_VALUE if debug else None,
|
||||
)
|
||||
|
||||
set_celery_flower_user(local_django_envs_path, value=celery_flower_user)
|
||||
set_celery_flower_password(
|
||||
local_django_envs_path, value=DEBUG_VALUE if debug else None
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
POSTGRES_HOST=postgres
|
||||
POSTGRES_PORT=5432
|
||||
POSTGRES_DB={{ cookiecutter.project_slug }}
|
||||
POSTGRES_USER=!!!SET POSTGRES_USER!!!
|
||||
POSTGRES_PASSWORD=!!!SET POSTGRES_PASSWORD!!!
|
||||
POSTGRES_USER=!!!SET POSTGRESQL_USER!!!
|
||||
POSTGRES_PASSWORD=!!!SET POSTGRESQL_PASSWORD!!!
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
POSTGRES_HOST=postgres
|
||||
POSTGRES_PORT=5432
|
||||
POSTGRES_DB={{ cookiecutter.project_slug }}
|
||||
POSTGRES_USER=!!!SET POSTGRES_USER!!!
|
||||
POSTGRES_PASSWORD=!!!SET POSTGRES_PASSWORD!!!
|
||||
POSTGRES_USER=!!!SET POSTGRESQL_USER!!!
|
||||
POSTGRES_PASSWORD=!!!SET POSTGRESQL_PASSWORD!!!
|
||||
|
|
Loading…
Reference in New Issue
Block a user