From 9f0c74664d8f90dacd40db3e30ccafc422272e2d Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Tue, 29 Dec 2020 11:59:31 +0100 Subject: [PATCH 1/7] Make "--email" optional in "create_superuser" manage command --- django_ynh/management/commands/create_superuser.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/django_ynh/management/commands/create_superuser.py b/django_ynh/management/commands/create_superuser.py index f69c2ba..263d45f 100644 --- a/django_ynh/management/commands/create_superuser.py +++ b/django_ynh/management/commands/create_superuser.py @@ -26,7 +26,7 @@ class Command(BaseCommand): parser.add_argument( "--email", action="store", - required=True, + default=None, ) def handle(self, *args, **options): @@ -40,7 +40,8 @@ class Command(BaseCommand): user.is_active = True user.is_staff = True user.is_superuser = True - user.email = email + if email: + user.email = email else: print(f'Create new super user "{username}"', file=sys.stderr) user = User.objects.create_superuser(username=username, email=email, password=None) From 3d8b18788e51385a896c59c019331301f77bb46d Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Tue, 29 Dec 2020 12:02:57 +0100 Subject: [PATCH 2/7] fix superuser setup --- django_ynh/local_test.py | 9 +-------- scripts/install | 7 ++++--- scripts/upgrade | 4 ++-- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/django_ynh/local_test.py b/django_ynh/local_test.py index cf64c7b..e691bfc 100755 --- a/django_ynh/local_test.py +++ b/django_ynh/local_test.py @@ -105,14 +105,7 @@ def create_local_test(django_settings_path, destination, runserver=False): if runserver: call_manage_py(final_home_path, 'migrate --no-input') call_manage_py(final_home_path, 'collectstatic --no-input') - - verbose_check_call( - command=( - f'{sys.executable} -m django_ynh.create_superuser' - f' --ds="{django_settings_name}" --username="test" --password="test123"' - ), - cwd=final_home_path, - ) + call_manage_py(final_home_path, 'create_superuser --username="test"') os.environ['DJANGO_SETTINGS_MODULE'] = django_settings_name diff --git a/scripts/install b/scripts/install index f949f81..a9014cc 100755 --- a/scripts/install +++ b/scripts/install @@ -159,9 +159,9 @@ touch "$final_path/local_settings.py" cp "../conf/urls.py" "$final_path/urls.py" #================================================= -# MIGRATE / COLLECTSTATIC / CREATEADMIN +# MIGRATE / COLLECTSTATIC / CREATE SUPERUSER #================================================= -ynh_script_progression --message="migrate/collectstatic/createadmin..." --weight=10 +ynh_script_progression --message="migrate/collectstatic/create superuser..." --weight=10 ( set +o nounset @@ -175,7 +175,8 @@ ynh_script_progression --message="migrate/collectstatic/createadmin..." --weight ./manage.py migrate --no-input ./manage.py collectstatic --no-input - python -m django_ynh.create_superuser --ds="django_ynh_demo_settings" --username="$admin" --email="$admin_mail" --password="$app" + # Create/update Django superuser (set unusable password, because auth done via SSOwat): + ./manage.py create_superuser --username="$admin" --email="$admin_mail" # Check the configuration # This may fail in some cases with errors, etc., but the app works and the user can fix issues later. diff --git a/scripts/upgrade b/scripts/upgrade index be9bdd7..d5578b9 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -147,9 +147,9 @@ touch "$final_path/local_settings.py" cp "../conf/urls.py" "$final_path/urls.py" #================================================= -# MIGRATE django_ynh +# MIGRATE / COLLECTSTATIC / CREATE SUPERUSER #================================================= -ynh_script_progression --message="migrate/collectstatic/createadmin..." --weight=10 +ynh_script_progression --message="migrate/collectstatic/create superuser..." --weight=10 ( set +o nounset From a58ba43e18202007d0437fbcc6a2126bbafcd9e6 Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Tue, 29 Dec 2020 12:03:35 +0100 Subject: [PATCH 3/7] fix serve static files --- conf/urls.py | 4 ---- django_ynh/local_test.py | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/conf/urls.py b/conf/urls.py index 9cf9d56..714ec0d 100644 --- a/conf/urls.py +++ b/conf/urls.py @@ -1,5 +1,4 @@ from django.conf import settings -from django.conf.urls import static from django.contrib import admin from django.urls import path @@ -12,6 +11,3 @@ urlpatterns = [ path(f'{settings.PATH_URL}/', admin.site.urls), path(f'{settings.PATH_URL}/debug/', request_media_debug_view), ] - -if settings.SERVE_FILES: - urlpatterns += static.static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) diff --git a/django_ynh/local_test.py b/django_ynh/local_test.py index e691bfc..42b86dc 100755 --- a/django_ynh/local_test.py +++ b/django_ynh/local_test.py @@ -119,7 +119,7 @@ def create_local_test(django_settings_path, destination, runserver=False): os.environ['HTTP_AUTHORIZATION'] = generate_basic_auth(username='test', password='test123') try: - call_manage_py(final_home_path, 'runserver --nostatic') + call_manage_py(final_home_path, 'runserver') except KeyboardInterrupt: print('\nBye ;)') From 722de42ecd818efd88c50d4174ee76597af135c0 Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Tue, 29 Dec 2020 12:06:04 +0100 Subject: [PATCH 4/7] release as v0.1.2rc1 --- README.md | 6 ++++-- django_ynh/__init__.py | 2 +- manifest.json | 2 +- pyproject.toml | 2 +- scripts/_common.sh | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1c0a23c..5553867 100644 --- a/README.md +++ b/README.md @@ -45,9 +45,11 @@ A password is not needed, because auth done via SSOwat ;) ## history -* [compare v0.1.0...master](https://github.com/YunoHost-Apps/django_ynh/compare/v0.1.0...master) **dev** +* [compare v0.1.2rc1...master](https://github.com/YunoHost-Apps/django_ynh/compare/v0.1.2rc1...master) **dev** * tbc -* [v0.1.1 - 28.12.2020](https://github.com/YunoHost-Apps/django_ynh/compare/v0.1.0...v0.1.1) +* [v0.1.2rc1 - 29.12.2020](https://github.com/YunoHost-Apps/django_ynh/compare/v0.1.1...v0.1.2rc1) **unreleased, yet** + * Bugfixes +* [v0.1.1 - 29.12.2020](https://github.com/YunoHost-Apps/django_ynh/compare/v0.1.0...v0.1.1) * Refactor "create_superuser" to a manage command, useable via "django_ynh" in `INSTALLED_APPS` * Generate "conf/requirements.txt" and use this file for install * rename own settings and urls (in `/conf/`) diff --git a/django_ynh/__init__.py b/django_ynh/__init__.py index df9144c..0b67b11 100644 --- a/django_ynh/__init__.py +++ b/django_ynh/__init__.py @@ -1 +1 @@ -__version__ = '0.1.1' +__version__ = '0.1.2rc1' diff --git a/manifest.json b/manifest.json index 23ab0b7..5030dc8 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "Glue code to package django projects as yunohost apps." }, - "version": "0.1.1~ynh1", + "version": "0.1.2rc1~ynh1", "url": "https://github.com/jedie/django_ynh", "license": "GPL-3.0", "maintainer": { diff --git a/pyproject.toml b/pyproject.toml index 84b053e..d308f0c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "django_ynh" -version = "0.1.1" +version = "0.1.2rc1" description = "Glue code to package django projects as yunohost apps." authors = ["JensDiemer "] license = "GPL" diff --git a/scripts/_common.sh b/scripts/_common.sh index 66100bd..661b75f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -28,7 +28,7 @@ log_file="${log_path}/django_ynh.log" pkg_dependencies="build-essential python3-dev python3-pip python3-venv git postgresql postgresql-contrib" # To install/upgrade this project via pip: -pip_install_string="django_ynh==0.1.1" +pip_install_string="django_ynh==0.1.2rc1" #================================================= # Redis HELPERS From dacee434ee3a73c81daac73c8c3c93232ed42507 Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Tue, 29 Dec 2020 12:14:00 +0100 Subject: [PATCH 5/7] copy conf/setup_user.py, too --- manifest.json | 2 +- scripts/install | 7 ++++--- scripts/upgrade | 13 +++++++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/manifest.json b/manifest.json index 5030dc8..9b95b52 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "Glue code to package django projects as yunohost apps." }, - "version": "0.1.2rc1~ynh1", + "version": "0.1.2rc1~ynh2", "url": "https://github.com/jedie/django_ynh", "license": "GPL-3.0", "maintainer": { diff --git a/scripts/install b/scripts/install index a9014cc..e48af2a 100755 --- a/scripts/install +++ b/scripts/install @@ -132,8 +132,6 @@ 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/settings.py" cp "../conf/settings.py" "$settings" @@ -154,9 +152,12 @@ ynh_store_file_checksum --file="$settings" ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" +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" + touch "$final_path/local_settings.py" -cp "../conf/urls.py" "$final_path/urls.py" #================================================= # MIGRATE / COLLECTSTATIC / CREATE SUPERUSER diff --git a/scripts/upgrade b/scripts/upgrade index d5578b9..69c0bce 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -118,9 +118,6 @@ 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/settings.py" ynh_backup_if_checksum_is_different --file="$settings" @@ -142,9 +139,17 @@ 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" +ynh_backup_if_checksum_is_different --file="$final_path/setup_user.py" +cp ../conf/setup_user.py "$final_path/setup_user.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" -cp "../conf/urls.py" "$final_path/urls.py" #================================================= # MIGRATE / COLLECTSTATIC / CREATE SUPERUSER From c8fc994914373293c7e7a5f49412b60ced877e2c Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Tue, 29 Dec 2020 12:32:44 +0100 Subject: [PATCH 6/7] Bugfix nginx config --- conf/nginx.conf | 2 +- manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 8c05d5e..7cb87c2 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -20,5 +20,5 @@ location __PATH__/ { proxy_connect_timeout 30; proxy_redirect off; - proxy_pass http://127.0.0.1:__PORT__/; + proxy_pass http://127.0.0.1:__PORT__; } diff --git a/manifest.json b/manifest.json index 9b95b52..1f9c26f 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "Glue code to package django projects as yunohost apps." }, - "version": "0.1.2rc1~ynh2", + "version": "0.1.2rc1~ynh3", "url": "https://github.com/jedie/django_ynh", "license": "GPL-3.0", "maintainer": { From a6082e44440df608ba4f593ee2455be6f3e8cc2d Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Tue, 29 Dec 2020 12:45:19 +0100 Subject: [PATCH 7/7] release as v0.1.2 --- README.md | 4 ++-- django_ynh/__init__.py | 2 +- manifest.json | 2 +- pyproject.toml | 2 +- scripts/_common.sh | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5553867..623c136 100644 --- a/README.md +++ b/README.md @@ -45,9 +45,9 @@ A password is not needed, because auth done via SSOwat ;) ## history -* [compare v0.1.2rc1...master](https://github.com/YunoHost-Apps/django_ynh/compare/v0.1.2rc1...master) **dev** +* [compare v0.1.2...master](https://github.com/YunoHost-Apps/django_ynh/compare/v0.1.2...master) **dev** * tbc -* [v0.1.2rc1 - 29.12.2020](https://github.com/YunoHost-Apps/django_ynh/compare/v0.1.1...v0.1.2rc1) **unreleased, yet** +* [v0.1.2 - 29.12.2020](https://github.com/YunoHost-Apps/django_ynh/compare/v0.1.1...v0.1.2) **unreleased, yet** * Bugfixes * [v0.1.1 - 29.12.2020](https://github.com/YunoHost-Apps/django_ynh/compare/v0.1.0...v0.1.1) * Refactor "create_superuser" to a manage command, useable via "django_ynh" in `INSTALLED_APPS` diff --git a/django_ynh/__init__.py b/django_ynh/__init__.py index 0b67b11..10939f0 100644 --- a/django_ynh/__init__.py +++ b/django_ynh/__init__.py @@ -1 +1 @@ -__version__ = '0.1.2rc1' +__version__ = '0.1.2' diff --git a/manifest.json b/manifest.json index 1f9c26f..b32247a 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "Glue code to package django projects as yunohost apps." }, - "version": "0.1.2rc1~ynh3", + "version": "0.1.2~ynh1", "url": "https://github.com/jedie/django_ynh", "license": "GPL-3.0", "maintainer": { diff --git a/pyproject.toml b/pyproject.toml index d308f0c..5f8d0f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "django_ynh" -version = "0.1.2rc1" +version = "0.1.2" description = "Glue code to package django projects as yunohost apps." authors = ["JensDiemer "] license = "GPL" diff --git a/scripts/_common.sh b/scripts/_common.sh index 661b75f..8ecea41 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -28,7 +28,7 @@ log_file="${log_path}/django_ynh.log" pkg_dependencies="build-essential python3-dev python3-pip python3-venv git postgresql postgresql-contrib" # To install/upgrade this project via pip: -pip_install_string="django_ynh==0.1.2rc1" +pip_install_string="django_ynh==0.1.2" #================================================= # Redis HELPERS