diff --git a/conf/manage.py b/conf/manage.py index 192f17f..a85e3b1 100755 --- a/conf/manage.py +++ b/conf/manage.py @@ -5,8 +5,9 @@ import sys def main(): - os.environ['DJANGO_SETTINGS_MODULE'] = 'ynh_for_runners_settings' + os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' from django.core.management import execute_from_command_line + execute_from_command_line(sys.argv) diff --git a/conf/setup_user.py b/conf/setup_user.py new file mode 100644 index 0000000..5d820de --- /dev/null +++ b/conf/setup_user.py @@ -0,0 +1,8 @@ +def setup_project_user(user): + """ + All users used the Django admin, so we need to set the "staff" user flag. + Called from django_ynh.sso_auth + """ + user.is_staff = True + user.save() + return user diff --git a/conf/wsgi.py b/conf/wsgi.py index 2c2dd58..018a0cc 100644 --- a/conf/wsgi.py +++ b/conf/wsgi.py @@ -2,7 +2,11 @@ WSGI config """ import os -os.environ['DJANGO_SETTINGS_MODULE'] = 'ynh_for_runners_settings' -from django.core.wsgi import get_wsgi_application -application = get_wsgi_application() \ No newline at end of file + +os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' + +from django.core.wsgi import get_wsgi_application # noqa + + +application = get_wsgi_application() diff --git a/scripts/change_url b/scripts/change_url index 6e300ed..ed7c174 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -116,10 +116,10 @@ fi ynh_script_progression --message="Modify Django-For-Runners's config file..." # save old settings file -settings="$final_path/ynh_for_runners_settings.py" +settings="$final_path/settings.py" ynh_backup_if_checksum_is_different --file="$settings" -cp "../conf/ynh_for_runners_settings.py" "$settings" +cp "../conf/settings.py" "$settings" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$settings" ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$settings" diff --git a/scripts/install b/scripts/install index cd81d32..8239fa6 100755 --- a/scripts/install +++ b/scripts/install @@ -132,10 +132,8 @@ ynh_store_file_checksum --file="$gunicorn_conf" cp ../conf/manage.py "$final_path/manage.py" chmod +x "$final_path/manage.py" -cp ../conf/wsgi.py "$final_path/wsgi.py" - -settings="$final_path/ynh_for_runners_settings.py" -cp "../conf/ynh_for_runners_settings.py" "$settings" +settings="$final_path/settings.py" +cp "../conf/settings.py" "$settings" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$settings" ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$settings" @@ -154,9 +152,11 @@ ynh_store_file_checksum --file="$settings" ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" -touch "$final_path/local_settings.py" +cp ../conf/setup_user.py "$final_path/setup_user.py" +cp ../conf/urls.py "$final_path/urls.py" +cp ../conf/wsgi.py "$final_path/wsgi.py" -cp "../conf/ynh_urls.py" "$final_path/ynh_urls.py" +touch "$final_path/local_settings.py" #================================================= # MIGRATE / COLLECTSTATIC / CREATEADMIN diff --git a/scripts/upgrade b/scripts/upgrade index 812acb7..4783c2f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -118,14 +118,11 @@ ynh_backup_if_checksum_is_different --file="$final_path/manage.py" cp ../conf/manage.py "$final_path/manage.py" chmod +x "$final_path/manage.py" -ynh_backup_if_checksum_is_different --file="$final_path/wsgi.py" -cp ../conf/wsgi.py "$final_path/wsgi.py" - # save old settings file -settings="$final_path/ynh_for_runners_settings.py" +settings="$final_path/settings.py" ynh_backup_if_checksum_is_different --file="$settings" -cp "../conf/ynh_for_runners_settings.py" "$settings" +cp "../conf/settings.py" "$settings" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$settings" ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$settings" @@ -142,9 +139,16 @@ ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" -- # Recalculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$settings" -touch "$final_path/local_settings.py" +ynh_backup_if_checksum_is_different --file="$final_path/setup_user.py" +cp ../conf/setup_user.py "$final_path/setup_user.py" -cp "../conf/ynh_urls.py" "$final_path/ynh_urls.py" +ynh_backup_if_checksum_is_different --file="$final_path/urls.py" +cp ../conf/urls.py "$final_path/urls.py" + +ynh_backup_if_checksum_is_different --file="$final_path/wsgi.py" +cp ../conf/wsgi.py "$final_path/wsgi.py" + +touch "$final_path/local_settings.py" #================================================= # MIGRATE PYINVENTORY