mirror of
https://github.com/YunoHost-Apps/django_example_ynh.git
synced 2024-09-03 18:26:21 +02:00
commit
4ceb5f47c5
11 changed files with 33 additions and 34 deletions
|
@ -45,9 +45,11 @@ A password is not needed, because auth done via SSOwat ;)
|
||||||
|
|
||||||
## history
|
## 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
|
* 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`
|
* Refactor "create_superuser" to a manage command, useable via "django_ynh" in `INSTALLED_APPS`
|
||||||
* Generate "conf/requirements.txt" and use this file for install
|
* Generate "conf/requirements.txt" and use this file for install
|
||||||
* rename own settings and urls (in `/conf/`)
|
* rename own settings and urls (in `/conf/`)
|
||||||
|
|
|
@ -20,5 +20,5 @@ location __PATH__/ {
|
||||||
proxy_connect_timeout 30;
|
proxy_connect_timeout 30;
|
||||||
proxy_redirect off;
|
proxy_redirect off;
|
||||||
|
|
||||||
proxy_pass http://127.0.0.1:__PORT__/;
|
proxy_pass http://127.0.0.1:__PORT__;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.conf.urls import static
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
|
@ -12,6 +11,3 @@ urlpatterns = [
|
||||||
path(f'{settings.PATH_URL}/', admin.site.urls),
|
path(f'{settings.PATH_URL}/', admin.site.urls),
|
||||||
path(f'{settings.PATH_URL}/debug/', request_media_debug_view),
|
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)
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
__version__ = '0.1.1'
|
__version__ = '0.1.2'
|
||||||
|
|
|
@ -105,14 +105,7 @@ def create_local_test(django_settings_path, destination, runserver=False):
|
||||||
if runserver:
|
if runserver:
|
||||||
call_manage_py(final_home_path, 'migrate --no-input')
|
call_manage_py(final_home_path, 'migrate --no-input')
|
||||||
call_manage_py(final_home_path, 'collectstatic --no-input')
|
call_manage_py(final_home_path, 'collectstatic --no-input')
|
||||||
|
call_manage_py(final_home_path, 'create_superuser --username="test"')
|
||||||
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,
|
|
||||||
)
|
|
||||||
|
|
||||||
os.environ['DJANGO_SETTINGS_MODULE'] = django_settings_name
|
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')
|
os.environ['HTTP_AUTHORIZATION'] = generate_basic_auth(username='test', password='test123')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
call_manage_py(final_home_path, 'runserver --nostatic')
|
call_manage_py(final_home_path, 'runserver')
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print('\nBye ;)')
|
print('\nBye ;)')
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Command(BaseCommand):
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--email",
|
"--email",
|
||||||
action="store",
|
action="store",
|
||||||
required=True,
|
default=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
|
@ -40,7 +40,8 @@ class Command(BaseCommand):
|
||||||
user.is_active = True
|
user.is_active = True
|
||||||
user.is_staff = True
|
user.is_staff = True
|
||||||
user.is_superuser = True
|
user.is_superuser = True
|
||||||
user.email = email
|
if email:
|
||||||
|
user.email = email
|
||||||
else:
|
else:
|
||||||
print(f'Create new super user "{username}"', file=sys.stderr)
|
print(f'Create new super user "{username}"', file=sys.stderr)
|
||||||
user = User.objects.create_superuser(username=username, email=email, password=None)
|
user = User.objects.create_superuser(username=username, email=email, password=None)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Glue code to package django projects as yunohost apps."
|
"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",
|
"url": "https://github.com/jedie/django_ynh",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "django_ynh"
|
name = "django_ynh"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
description = "Glue code to package django projects as yunohost apps."
|
description = "Glue code to package django projects as yunohost apps."
|
||||||
authors = ["JensDiemer <git@jensdiemer.de>"]
|
authors = ["JensDiemer <git@jensdiemer.de>"]
|
||||||
license = "GPL"
|
license = "GPL"
|
||||||
|
|
|
@ -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"
|
pkg_dependencies="build-essential python3-dev python3-pip python3-venv git postgresql postgresql-contrib"
|
||||||
|
|
||||||
# To install/upgrade this project via pip:
|
# 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
|
# Redis HELPERS
|
||||||
|
|
|
@ -132,8 +132,6 @@ ynh_store_file_checksum --file="$gunicorn_conf"
|
||||||
cp ../conf/manage.py "$final_path/manage.py"
|
cp ../conf/manage.py "$final_path/manage.py"
|
||||||
chmod +x "$final_path/manage.py"
|
chmod +x "$final_path/manage.py"
|
||||||
|
|
||||||
cp ../conf/wsgi.py "$final_path/wsgi.py"
|
|
||||||
|
|
||||||
settings="$final_path/settings.py"
|
settings="$final_path/settings.py"
|
||||||
cp "../conf/settings.py" "$settings"
|
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"
|
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"
|
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
|
set +o nounset
|
||||||
|
@ -175,7 +176,8 @@ ynh_script_progression --message="migrate/collectstatic/createadmin..." --weight
|
||||||
./manage.py migrate --no-input
|
./manage.py migrate --no-input
|
||||||
./manage.py collectstatic --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
|
# Check the configuration
|
||||||
# This may fail in some cases with errors, etc., but the app works and the user can fix issues later.
|
# This may fail in some cases with errors, etc., but the app works and the user can fix issues later.
|
||||||
|
|
|
@ -118,9 +118,6 @@ ynh_backup_if_checksum_is_different --file="$final_path/manage.py"
|
||||||
cp ../conf/manage.py "$final_path/manage.py"
|
cp ../conf/manage.py "$final_path/manage.py"
|
||||||
chmod +x "$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
|
# save old settings file
|
||||||
settings="$final_path/settings.py"
|
settings="$final_path/settings.py"
|
||||||
ynh_backup_if_checksum_is_different --file="$settings"
|
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
|
# Recalculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum --file="$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"
|
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
|
set +o nounset
|
||||||
|
|
Loading…
Reference in a new issue