diff --git a/README.md b/README.md index 1c0a23c..623c136 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.2...master](https://github.com/YunoHost-Apps/django_ynh/compare/v0.1.2...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.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` * Generate "conf/requirements.txt" and use this file for install * rename own settings and urls (in `/conf/`) 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/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/__init__.py b/django_ynh/__init__.py index df9144c..10939f0 100644 --- a/django_ynh/__init__.py +++ b/django_ynh/__init__.py @@ -1 +1 @@ -__version__ = '0.1.1' +__version__ = '0.1.2' diff --git a/django_ynh/local_test.py b/django_ynh/local_test.py index cf64c7b..42b86dc 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 @@ -126,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 ;)') 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) diff --git a/manifest.json b/manifest.json index 23ab0b7..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.1~ynh1", + "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 84b053e..5f8d0f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "django_ynh" -version = "0.1.1" +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 66100bd..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.1" +pip_install_string="django_ynh==0.1.2" #================================================= # Redis HELPERS diff --git a/scripts/install b/scripts/install index f949f81..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,14 +152,17 @@ 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 / 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 +176,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..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,14 +139,22 @@ 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 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