mirror of
https://github.com/YunoHost-Apps/django_example_ynh.git
synced 2024-09-03 18:26:21 +02:00
parent
e58d2c9535
commit
54d620034a
34 changed files with 1561 additions and 849 deletions
|
@ -10,7 +10,7 @@ trim_trailing_whitespace = true
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
|
||||||
[*.py]
|
[*.py]
|
||||||
line_length = 119
|
max_line_length = 100
|
||||||
|
|
||||||
[{Makefile,**.mk}]
|
[{Makefile,**.mk}]
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
|
@ -18,4 +18,3 @@ insert_final_newline = false
|
||||||
|
|
||||||
[*.yml]
|
[*.yml]
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
indent_size = 4
|
|
||||||
|
|
55
.github/ISSUE_TEMPLATE.md
vendored
Normal file
55
.github/ISSUE_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**How to post a meaningful bug report**
|
||||||
|
1. *Read this whole template first.*
|
||||||
|
2. *Determine if you are on the right place:*
|
||||||
|
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
|
||||||
|
- *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
|
||||||
|
- *When in doubt, post here and we will figure it out together.*
|
||||||
|
3. *Delete the italic comments as you write over them below, and remove this guide.*
|
||||||
|
---
|
||||||
|
|
||||||
|
### Describe the bug
|
||||||
|
|
||||||
|
*A clear and concise description of what the bug is.*
|
||||||
|
|
||||||
|
### Context
|
||||||
|
|
||||||
|
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
|
||||||
|
- YunoHost version: x.x.x
|
||||||
|
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
|
||||||
|
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes*
|
||||||
|
- If yes, please explain:
|
||||||
|
- Using, or trying to install package version/branch:
|
||||||
|
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
|
||||||
|
|
||||||
|
### Steps to reproduce
|
||||||
|
|
||||||
|
- *If you performed a command from the CLI, the command itself is enough. For example:*
|
||||||
|
```sh
|
||||||
|
sudo yunohost app install the_app
|
||||||
|
```
|
||||||
|
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
|
||||||
|
- *If the error occurs in your browser, explain what you did:*
|
||||||
|
1. *Go to '...'*
|
||||||
|
2. *Click on '...'*
|
||||||
|
3. *Scroll down to '...'*
|
||||||
|
4. *See error*
|
||||||
|
|
||||||
|
### Expected behavior
|
||||||
|
|
||||||
|
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
|
||||||
|
|
||||||
|
### Logs
|
||||||
|
|
||||||
|
*When an operation fails, YunoHost provides a simple way to share the logs.*
|
||||||
|
- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*
|
||||||
|
- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*
|
||||||
|
|
||||||
|
*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*
|
||||||
|
|
||||||
|
*If applicable and useful, add screenshots to help explain your problem.*
|
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
## Problem
|
||||||
|
|
||||||
|
- *Description of why you made this PR*
|
||||||
|
|
||||||
|
## Solution
|
||||||
|
|
||||||
|
- *And how do you fix that problem*
|
||||||
|
|
||||||
|
## PR Status
|
||||||
|
|
||||||
|
- [ ] Code finished and ready to be reviewed/tested
|
||||||
|
- [ ] The fix/enhancement were manually tested (if applicable)
|
||||||
|
|
||||||
|
## Automatic tests
|
||||||
|
|
||||||
|
Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization)
|
5
.github/workflows/package_linter.yml
vendored
5
.github/workflows/package_linter.yml
vendored
|
@ -1,9 +1,12 @@
|
||||||
name: YunoHost apps package linter
|
name: YunoHost apps package linter
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 8 * * *'
|
- cron: '0 8 * * *'
|
||||||
push:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
|
|
26
.github/workflows/pytest.yml
vendored
26
.github/workflows/pytest.yml
vendored
|
@ -1,9 +1,12 @@
|
||||||
name: pytest
|
name: pytest
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 8 * * *'
|
- cron: '0 8 * * *'
|
||||||
push:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
|
@ -11,11 +14,16 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
max-parallel: 2
|
max-parallel: 2
|
||||||
matrix:
|
matrix:
|
||||||
python-version: [3.9, 3.8, 3.7]
|
python-version: ["3.10", "3.9", "3.8", "3.7"]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: 'fetch master'
|
||||||
|
run: |
|
||||||
|
git fetch origin master
|
||||||
- name: 'Set up Python ${{ matrix.python-version }}'
|
- name: 'Set up Python ${{ matrix.python-version }}'
|
||||||
uses: actions/setup-python@v1
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: '${{ matrix.python-version }}'
|
python-version: '${{ matrix.python-version }}'
|
||||||
|
|
||||||
|
@ -33,9 +41,7 @@ jobs:
|
||||||
make pytest
|
make pytest
|
||||||
|
|
||||||
- name: 'Upload coverage report'
|
- name: 'Upload coverage report'
|
||||||
run: bash <(curl -s https://codecov.io/bash)
|
uses: codecov/codecov-action@v2
|
||||||
|
with:
|
||||||
- name: 'Run linters'
|
fail_ci_if_error: false
|
||||||
if: matrix.python-version == '3.8'
|
verbose: true
|
||||||
run: |
|
|
||||||
make lint
|
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,6 +3,7 @@
|
||||||
!.editorconfig
|
!.editorconfig
|
||||||
!.flake8
|
!.flake8
|
||||||
!.gitignore
|
!.gitignore
|
||||||
|
!/doc/screenshots/.gitkeep
|
||||||
__pycache__
|
__pycache__
|
||||||
secret.txt
|
secret.txt
|
||||||
/local_test/
|
/local_test/
|
||||||
|
|
8
Makefile
8
Makefile
|
@ -1,5 +1,5 @@
|
||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
MAX_LINE_LENGTH := 119
|
MAX_LINE_LENGTH := 100
|
||||||
|
|
||||||
all: help
|
all: help
|
||||||
|
|
||||||
|
@ -29,12 +29,12 @@ update: install-poetry ## update the sources and installation and generate "con
|
||||||
poetry export -f requirements.txt --output conf/requirements.txt
|
poetry export -f requirements.txt --output conf/requirements.txt
|
||||||
|
|
||||||
lint: ## Run code formatters and linter
|
lint: ## Run code formatters and linter
|
||||||
poetry run flynt --fail-on-change --line_length=${MAX_LINE_LENGTH} .
|
poetry run flynt --fail-on-change --line-length=${MAX_LINE_LENGTH} .
|
||||||
poetry run isort --check-only .
|
poetry run isort --check-only .
|
||||||
poetry run flake8 .
|
poetry run flake8 .
|
||||||
|
|
||||||
fix-code-style: ## Fix code formatting
|
fix-code-style: ## Fix code formatting
|
||||||
poetry run flynt --line_length=${MAX_LINE_LENGTH} .
|
poetry run flynt --line-length=${MAX_LINE_LENGTH} .
|
||||||
poetry run black --verbose --safe --line-length=${MAX_LINE_LENGTH} --skip-string-normalization .
|
poetry run black --verbose --safe --line-length=${MAX_LINE_LENGTH} --skip-string-normalization .
|
||||||
poetry run isort .
|
poetry run isort .
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ tox: check-poetry ## Run pytest via tox with all environments
|
||||||
poetry run tox
|
poetry run tox
|
||||||
|
|
||||||
pytest: install ## Run pytest
|
pytest: install ## Run pytest
|
||||||
poetry run python3 ./run_pytest.py
|
poetry run pytest
|
||||||
|
|
||||||
local-test: install ## Run local_test.py to run the project locally
|
local-test: install ## Run local_test.py to run the project locally
|
||||||
poetry run python3 ./local_test.py
|
poetry run python3 ./local_test.py
|
||||||
|
|
75
README.md
75
README.md
|
@ -1,4 +1,21 @@
|
||||||
# django_example_ynh
|
<!--
|
||||||
|
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
|
||||||
|
It shall NOT be edited by hand.
|
||||||
|
-->
|
||||||
|
|
||||||
|
# Django Example for YunoHost
|
||||||
|
|
||||||
|
[](https://dash.yunohost.org/appci/app/django_example_ynh)  
|
||||||
|
[](https://install-app.yunohost.org/?app=django_example_ynh)
|
||||||
|
|
||||||
|
*[Lire ce readme en français.](./README_fr.md)*
|
||||||
|
|
||||||
|
> *This package allows you to install Django Example quickly and simply on a YunoHost server.
|
||||||
|
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
[](https://github.com/YunoHost-Apps/django_example_ynh/actions/workflows/pytest.yml) [](https://github.com/YunoHost-Apps/django_example_ynh/actions/workflows/package_linter.yml)
|
||||||
|
|
||||||
Demo [YunoHost Application](https://install-app.yunohost.org/?app=django_example_ynh) to demonstrate the integration of a Django project under YunoHost.
|
Demo [YunoHost Application](https://install-app.yunohost.org/?app=django_example_ynh) to demonstrate the integration of a Django project under YunoHost.
|
||||||
|
|
||||||
|
@ -9,6 +26,10 @@ Demo [YunoHost Application](https://install-app.yunohost.org/?app=django_example
|
||||||
Pull requests welcome ;)
|
Pull requests welcome ;)
|
||||||
|
|
||||||
|
|
||||||
|
**Shipped version:** 0.3.0~ynh1
|
||||||
|
|
||||||
|
## Disclaimers / important information
|
||||||
|
|
||||||
## local test
|
## local test
|
||||||
|
|
||||||
For quicker developing of django_example_ynh in the context of YunoHost app,
|
For quicker developing of django_example_ynh in the context of YunoHost app,
|
||||||
|
@ -86,22 +107,21 @@ These projects used `django_example_ynh`:
|
||||||
|
|
||||||
# Developer info
|
# Developer info
|
||||||
|
|
||||||
|
The App project will be stored under `__FINALPATH__` (e.g.: `/opt/yunohost/$app`) that's Django's `settings.FINALPATH`
|
||||||
|
"static" / "media" files to serve via nginx are under `__PUBLIC_PATH__` (e.g.: `/var/www/$app`) that's `settings.PUBLIC_PATH`
|
||||||
|
|
||||||
## package installation / debugging
|
## package installation / debugging
|
||||||
|
|
||||||
Please send your pull request to https://github.com/YunoHost-Apps/django_example_ynh
|
This app is not in YunoHost app catalog. Test install, e.g.:
|
||||||
|
|
||||||
Try 'main' branch, e.g.:
|
|
||||||
```bash
|
```bash
|
||||||
sudo yunohost app install https://github.com/YunoHost-Apps/django_example_ynh/tree/master --debug
|
~# git clone https://github.com/YunoHost-Apps/django_example_ynh.git
|
||||||
or
|
~# yunohost app install django_example_ynh/ -f
|
||||||
sudo yunohost app upgrade django_example_ynh -u https://github.com/YunoHost-Apps/django_example_ynh/tree/master --debug
|
|
||||||
```
|
```
|
||||||
|
To update:
|
||||||
Try 'testing' branch, e.g.:
|
|
||||||
```bash
|
```bash
|
||||||
sudo yunohost app install https://github.com/YunoHost-Apps/django_example_ynh/tree/testing --debug
|
~# cd django_example_ynh
|
||||||
or
|
~/django_example_ynh# git fetch && git reset --hard origin/testing
|
||||||
sudo yunohost app upgrade django_example_ynh -u https://github.com/YunoHost-Apps/django_example_ynh/tree/testing --debug
|
~/django_example_ynh# yunohost app upgrade django_example_ynh -u . -F
|
||||||
```
|
```
|
||||||
|
|
||||||
To remove call e.g.:
|
To remove call e.g.:
|
||||||
|
@ -120,8 +140,11 @@ yunohost app remove django_example_ynh
|
||||||
yunohost backup restore 20201223-163434 --apps django_example_ynh
|
yunohost backup restore 20201223-163434 --apps django_example_ynh
|
||||||
```
|
```
|
||||||
|
|
||||||
Debug installation, e.g.:
|
Debug the installation, e.g.:
|
||||||
```bash
|
```bash
|
||||||
|
root@yunohost:~# cat /etc/yunohost/apps/django_example_ynh/settings.yml
|
||||||
|
...
|
||||||
|
|
||||||
root@yunohost:~# ls -la /var/www/django_example_ynh/
|
root@yunohost:~# ls -la /var/www/django_example_ynh/
|
||||||
total 18
|
total 18
|
||||||
drwxr-xr-x 4 root root 4 Dec 8 08:36 .
|
drwxr-xr-x 4 root root 4 Dec 8 08:36 .
|
||||||
|
@ -151,10 +174,34 @@ BASE_PATH:/opt/yunohost/django_example_ynh
|
||||||
System check identified no issues (0 silenced).
|
System check identified no issues (0 silenced).
|
||||||
|
|
||||||
root@yunohost:~# tail -f /var/log/django_example_ynh/django_example_ynh.log
|
root@yunohost:~# tail -f /var/log/django_example_ynh/django_example_ynh.log
|
||||||
root@yunohost:~# cat /etc/systemd/system/django_example_ynh.service
|
root@yunohost:~# cat /etc/systemd/system/systemd.service
|
||||||
|
...
|
||||||
|
|
||||||
root@yunohost:~# systemctl reload-or-restart django_example_ynh
|
root@yunohost:~# systemctl reload-or-restart django_example_ynh
|
||||||
root@yunohost:~# journalctl --unit=django_example_ynh --follow
|
root@yunohost:~# journalctl --unit=django_example_ynh --follow
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Documentation and resources
|
||||||
|
|
||||||
|
* Official app website: <https://github.com/YunoHost-Apps/django_example_ynh>
|
||||||
|
* Official user documentation: <https://github.com/YunoHost-Apps/django_example_ynh>
|
||||||
|
* Official admin documentation: <https://github.com/YunoHost-Apps/django_example_ynh>
|
||||||
|
* Upstream app code repository: <https://github.com/YunoHost-Apps/django_example_ynh>
|
||||||
|
* YunoHost documentation for this app: <https://yunohost.org/app_django_example_ynh>
|
||||||
|
* Report a bug: <https://github.com/YunoHost-Apps/django_example_ynh_ynh/issues>
|
||||||
|
|
||||||
|
## Developer info
|
||||||
|
|
||||||
|
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/django_example_ynh_ynh/tree/testing).
|
||||||
|
|
||||||
|
To try the testing branch, please proceed like that.
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
sudo yunohost app install https://github.com/YunoHost-Apps/django_example_ynh_ynh/tree/testing --debug
|
||||||
|
or
|
||||||
|
sudo yunohost app upgrade django_example_ynh -u https://github.com/YunoHost-Apps/django_example_ynh_ynh/tree/testing --debug
|
||||||
|
```
|
||||||
|
|
||||||
|
**More info regarding app packaging:** <https://yunohost.org/packaging_apps>
|
||||||
|
|
207
README_fr.md
Normal file
207
README_fr.md
Normal file
|
@ -0,0 +1,207 @@
|
||||||
|
<!--
|
||||||
|
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
|
||||||
|
It shall NOT be edited by hand.
|
||||||
|
-->
|
||||||
|
|
||||||
|
# Django Example pour YunoHost
|
||||||
|
|
||||||
|
[](https://dash.yunohost.org/appci/app/django_example_ynh)  
|
||||||
|
[](https://install-app.yunohost.org/?app=django_example_ynh)
|
||||||
|
|
||||||
|
*[Read this readme in english.](./README.md)*
|
||||||
|
|
||||||
|
> *Ce package vous permet d'installer Django Example rapidement et simplement sur un serveur YunoHost.
|
||||||
|
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
|
||||||
|
|
||||||
|
## Vue d'ensemble
|
||||||
|
|
||||||
|
[](https://github.com/YunoHost-Apps/django_example_ynh/actions/workflows/pytest.yml) [](https://github.com/YunoHost-Apps/django_example_ynh/actions/workflows/package_linter.yml)
|
||||||
|
|
||||||
|
Demo [YunoHost Application](https://install-app.yunohost.org/?app=django_example_ynh) to demonstrate the integration of a Django project under YunoHost.
|
||||||
|
|
||||||
|
[](https://dash.yunohost.org/appci/app/django_example_ynh)  
|
||||||
|
[](https://install-app.yunohost.org/?app=django_example_ynh)
|
||||||
|
|
||||||
|
|
||||||
|
Pull requests welcome ;)
|
||||||
|
|
||||||
|
|
||||||
|
**Version incluse :** 0.3.0~ynh1
|
||||||
|
|
||||||
|
## Avertissements / informations importantes
|
||||||
|
|
||||||
|
## local test
|
||||||
|
|
||||||
|
For quicker developing of django_example_ynh in the context of YunoHost app,
|
||||||
|
it's possible to run the Django developer server with the settings
|
||||||
|
and urls made for YunoHost installation.
|
||||||
|
|
||||||
|
e.g.:
|
||||||
|
```bash
|
||||||
|
~$ git clone https://github.com/YunoHost-Apps/django_example_ynh.git
|
||||||
|
~$ cd django_example_ynh/
|
||||||
|
~/django_example_ynh$ make
|
||||||
|
install-poetry install or update poetry
|
||||||
|
install install project via poetry
|
||||||
|
update update the sources and installation and generate "conf/requirements.txt"
|
||||||
|
lint Run code formatters and linter
|
||||||
|
fix-code-style Fix code formatting
|
||||||
|
tox-listenvs List all tox test environments
|
||||||
|
tox Run pytest via tox with all environments
|
||||||
|
pytest Run pytest
|
||||||
|
publish Release new version to PyPi
|
||||||
|
local-test Run local_test.py to run the project locally
|
||||||
|
local-diff-settings Run "manage.py diffsettings" with local test
|
||||||
|
|
||||||
|
~/django_example_ynh$ make install-poetry
|
||||||
|
~/django_example_ynh$ make install
|
||||||
|
~/django_example_ynh$ make local-test
|
||||||
|
```
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
* SQlite database will be used
|
||||||
|
* A super user with username `test` and password `test` is created
|
||||||
|
* The page is available under `http://127.0.0.1:8000/app_path/`
|
||||||
|
|
||||||
|
|
||||||
|
## history
|
||||||
|
|
||||||
|
* [compare v0.1.5...master](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.2.0...master) **dev**
|
||||||
|
* tbc
|
||||||
|
* [v0.2.0 - 15.09.2021](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.1.5...v0.2.0)
|
||||||
|
* rename/split `django_example_ynh` into:
|
||||||
|
* [django_yunohost_integration](https://github.com/jedie/django_yunohost_integration) - Python package with the glue code to integrate a Django project with YunoHost
|
||||||
|
* [django_example_ynh](https://github.com/YunoHost-Apps/django_example_ynh) - Demo YunoHost App to demonstrate the integration of a Django project under YunoHost
|
||||||
|
* [v0.1.5 - 19.01.2021](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.1.4...v0.1.5)
|
||||||
|
* Make some deps `gunicorn`, `psycopg2-binary`, `django-redis`, `django-axes` optional
|
||||||
|
* [v0.1.4 - 08.01.2021](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.1.3...v0.1.4)
|
||||||
|
* Bugfix [CSRF verification failed on POST requests #7](https://github.com/YunoHost-Apps/django_example_ynh/issues/7)
|
||||||
|
* [v0.1.3 - 08.01.2021](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.1.2...v0.1.3)
|
||||||
|
* set "DEBUG = True" in local_test (so static files are served and auth works)
|
||||||
|
* Bugfixes and cleanups
|
||||||
|
* [v0.1.2 - 29.12.2020](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.1.1...v0.1.2)
|
||||||
|
* Bugfixes
|
||||||
|
* [v0.1.1 - 29.12.2020](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.1.0...v0.1.1)
|
||||||
|
* Refactor "create_superuser" to a manage command, useable via "django_example_ynh" in `INSTALLED_APPS`
|
||||||
|
* Generate "conf/requirements.txt" and use this file for install
|
||||||
|
* rename own settings and urls (in `/conf/`)
|
||||||
|
* [v0.1.0 - 28.12.2020](https://github.com/YunoHost-Apps/django_example_ynh/compare/f578f14...v0.1.0)
|
||||||
|
* first working state
|
||||||
|
* [23.12.2020](https://github.com/YunoHost-Apps/django_example_ynh/commit/f578f144a3a6d11d7044597c37d550d29c247773)
|
||||||
|
* init the project
|
||||||
|
|
||||||
|
|
||||||
|
## Links
|
||||||
|
|
||||||
|
* Report a bug about this package: https://github.com/YunoHost-Apps/django_example_ynh
|
||||||
|
* YunoHost website: https://yunohost.org/
|
||||||
|
* PyPi package: https://pypi.org/project/django-ynh/
|
||||||
|
|
||||||
|
These projects used `django_example_ynh`:
|
||||||
|
|
||||||
|
* https://github.com/YunoHost-Apps/django_example_ynh
|
||||||
|
* https://github.com/YunoHost-Apps/django-for-runners_ynh
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Developer info
|
||||||
|
|
||||||
|
The App project will be stored under `__FINALPATH__` (e.g.: `/opt/yunohost/$app`) that's Django's `settings.FINALPATH`
|
||||||
|
"static" / "media" files to serve via nginx are under `__PUBLIC_PATH__` (e.g.: `/var/www/$app`) that's `settings.PUBLIC_PATH`
|
||||||
|
|
||||||
|
## package installation / debugging
|
||||||
|
|
||||||
|
This app is not in YunoHost app catalog. Test install, e.g.:
|
||||||
|
```bash
|
||||||
|
~# git clone https://github.com/YunoHost-Apps/django_example_ynh.git
|
||||||
|
~# yunohost app install django_example_ynh/ -f
|
||||||
|
```
|
||||||
|
To update:
|
||||||
|
```bash
|
||||||
|
~# cd django_example_ynh
|
||||||
|
~/django_example_ynh# git fetch && git reset --hard origin/testing
|
||||||
|
~/django_example_ynh# yunohost app upgrade django_example_ynh -u . -F
|
||||||
|
```
|
||||||
|
|
||||||
|
To remove call e.g.:
|
||||||
|
```bash
|
||||||
|
sudo yunohost app remove django_example_ynh
|
||||||
|
```
|
||||||
|
|
||||||
|
Backup / remove / restore cycle, e.g.:
|
||||||
|
```bash
|
||||||
|
yunohost backup create --apps django_example_ynh
|
||||||
|
yunohost backup list
|
||||||
|
archives:
|
||||||
|
- django_example_ynh-pre-upgrade1
|
||||||
|
- 20201223-163434
|
||||||
|
yunohost app remove django_example_ynh
|
||||||
|
yunohost backup restore 20201223-163434 --apps django_example_ynh
|
||||||
|
```
|
||||||
|
|
||||||
|
Debug the installation, e.g.:
|
||||||
|
```bash
|
||||||
|
root@yunohost:~# cat /etc/yunohost/apps/django_example_ynh/settings.yml
|
||||||
|
...
|
||||||
|
|
||||||
|
root@yunohost:~# ls -la /var/www/django_example_ynh/
|
||||||
|
total 18
|
||||||
|
drwxr-xr-x 4 root root 4 Dec 8 08:36 .
|
||||||
|
drwxr-xr-x 6 root root 6 Dec 8 08:36 ..
|
||||||
|
drwxr-xr-x 2 root root 2 Dec 8 08:36 media
|
||||||
|
drwxr-xr-x 7 root root 8 Dec 8 08:40 static
|
||||||
|
|
||||||
|
root@yunohost:~# ls -la /opt/yunohost/django_example_ynh/
|
||||||
|
total 58
|
||||||
|
drwxr-xr-x 5 django_example_ynh django_example_ynh 11 Dec 8 08:39 .
|
||||||
|
drwxr-xr-x 3 root root 3 Dec 8 08:36 ..
|
||||||
|
-rw-r--r-- 1 django_example_ynh django_example_ynh 460 Dec 8 08:39 gunicorn.conf.py
|
||||||
|
-rw-r--r-- 1 django_example_ynh django_example_ynh 0 Dec 8 08:39 local_settings.py
|
||||||
|
-rwxr-xr-x 1 django_example_ynh django_example_ynh 274 Dec 8 08:39 manage.py
|
||||||
|
-rw-r--r-- 1 django_example_ynh django_example_ynh 171 Dec 8 08:39 secret.txt
|
||||||
|
drwxr-xr-x 6 django_example_ynh django_example_ynh 6 Dec 8 08:37 venv
|
||||||
|
-rw-r--r-- 1 django_example_ynh django_example_ynh 115 Dec 8 08:39 wsgi.py
|
||||||
|
-rw-r--r-- 1 django_example_ynh django_example_ynh 4737 Dec 8 08:39 django_example_ynh_demo_settings.py
|
||||||
|
|
||||||
|
root@yunohost:~# cd /opt/yunohost/django_example_ynh/
|
||||||
|
root@yunohost:/opt/yunohost/django_example_ynh# source venv/bin/activate
|
||||||
|
(venv) root@yunohost:/opt/yunohost/django_example_ynh# ./manage.py check
|
||||||
|
django_example_ynh v0.8.2 (Django v2.2.17)
|
||||||
|
DJANGO_SETTINGS_MODULE='django_example_ynh_demo_settings'
|
||||||
|
PROJECT_PATH:/opt/yunohost/django_example_ynh/venv/lib/python3.7/site-packages
|
||||||
|
BASE_PATH:/opt/yunohost/django_example_ynh
|
||||||
|
System check identified no issues (0 silenced).
|
||||||
|
|
||||||
|
root@yunohost:~# tail -f /var/log/django_example_ynh/django_example_ynh.log
|
||||||
|
root@yunohost:~# cat /etc/systemd/system/systemd.service
|
||||||
|
...
|
||||||
|
|
||||||
|
root@yunohost:~# systemctl reload-or-restart django_example_ynh
|
||||||
|
root@yunohost:~# journalctl --unit=django_example_ynh --follow
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Documentations et ressources
|
||||||
|
|
||||||
|
* Site officiel de l'app : <https://github.com/YunoHost-Apps/django_example_ynh>
|
||||||
|
* Documentation officielle utilisateur : <https://github.com/YunoHost-Apps/django_example_ynh>
|
||||||
|
* Documentation officielle de l'admin : <https://github.com/YunoHost-Apps/django_example_ynh>
|
||||||
|
* Dépôt de code officiel de l'app : <https://github.com/YunoHost-Apps/django_example_ynh>
|
||||||
|
* Documentation YunoHost pour cette app : <https://yunohost.org/app_django_example_ynh>
|
||||||
|
* Signaler un bug : <https://github.com/YunoHost-Apps/django_example_ynh_ynh/issues>
|
||||||
|
|
||||||
|
## Informations pour les développeurs
|
||||||
|
|
||||||
|
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/django_example_ynh_ynh/tree/testing).
|
||||||
|
|
||||||
|
Pour essayer la branche testing, procédez comme suit.
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
sudo yunohost app install https://github.com/YunoHost-Apps/django_example_ynh_ynh/tree/testing --debug
|
||||||
|
ou
|
||||||
|
sudo yunohost app upgrade django_example_ynh -u https://github.com/YunoHost-Apps/django_example_ynh_ynh/tree/testing --debug
|
||||||
|
```
|
||||||
|
|
||||||
|
**Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>
|
|
@ -17,4 +17,4 @@ accesslog = '__LOG_FILE__'
|
||||||
errorlog = '__LOG_FILE__'
|
errorlog = '__LOG_FILE__'
|
||||||
|
|
||||||
# https://docs.gunicorn.org/en/latest/settings.html#pidfile
|
# https://docs.gunicorn.org/en/latest/settings.html#pidfile
|
||||||
pidfile = '__FINAL_HOME_PATH__/gunicorn.pid'
|
pidfile = '__FINALPATH__/gunicorn.pid'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python3
|
#!__FINALPATH__/venv/bin/python
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
location __PATH__/static/ {
|
location __PATH__/static/ {
|
||||||
# Django static files
|
# Service static files by nginx
|
||||||
|
# e.g.: /var/www/$app/static
|
||||||
alias __PUBLIC_PATH__/static/;
|
alias __PUBLIC_PATH__/static/;
|
||||||
expires 30d;
|
expires 30d;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,65 +1,128 @@
|
||||||
asgiref==3.3.1; python_version >= "3.7" and python_full_version < "4.0.0" \
|
asgiref==3.5.2; python_version >= "3.7" and python_full_version < "4.0.0" \
|
||||||
--hash=sha256:5ee950735509d04eb673bd7f7120f8fa1c9e2df495394992c73234d526907e17 \
|
--hash=sha256:1d2880b792ae8757289136f1db2b7b99100ce959b2aa57fd69dab783d05afac4 \
|
||||||
--hash=sha256:7162a3cb30ab0609f1a4c95938fd73e8604f63bdba516a7f7d64b83ff09478f0
|
--hash=sha256:4a29362a6acebe09bf1d6640db38c1dc3d9217c68e6f9f6204d72667fc19a424
|
||||||
django-axes==5.13.1; python_version >= "3.7" and python_version < "4.0" and python_full_version < "4.0.0" \
|
async-timeout==4.0.2; python_version >= "3.7" and python_full_version < "4.0.0" \
|
||||||
--hash=sha256:8f7870dc18ace6155127073bffe7276719c71c5ad4e67b45abedc0207f64a2f6 \
|
--hash=sha256:2163e1640ddb52b7a8c80d0a67a08587e5d245cc9c553a74a847056bc2976b15 \
|
||||||
--hash=sha256:aef814f738742b01cc7730cd2bebe3e5b462b807fd6c2ed609b62437ccc71f80
|
--hash=sha256:8ca1e4fcf50d07413d66d1a5e416e42cfdf5851c981d679a09851a6853383b3c
|
||||||
django-ipware==3.0.2; python_version >= "3.7" and python_version < "4.0" and python_full_version < "4.0.0" \
|
deprecated==1.2.13; python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version < "4.0.0" and python_full_version >= "3.4.0" \
|
||||||
--hash=sha256:c7df8e1410a8e5d6b1fbae58728402ea59950f043c3582e033e866f0f0cf5e94
|
--hash=sha256:64756e3e14c8c5eea9795d93c524551432a0be75629f8f29e67ab8caf076c76d \
|
||||||
django-redis==4.12.1; python_version >= "3.7" and python_full_version < "4.0.0" \
|
--hash=sha256:43ac5335da90c31c24ba028af536a91d41d53f9e6901ddb021bcc572ce44e38d
|
||||||
--hash=sha256:306589c7021e6468b2656edc89f62b8ba67e8d5a1c8877e2688042263daa7a63 \
|
django-axes==5.36.0; python_version >= "3.7" and python_full_version < "4.0.0" \
|
||||||
--hash=sha256:1133b26b75baa3664164c3f44b9d5d133d1b8de45d94d79f38d1adc5b1d502e5
|
--hash=sha256:bac08a7047fde26ffb54813c971fd40eeadb4ecb8d342a6e47d53de666d1a792 \
|
||||||
django-yunohost-integration==0.2.0a0; python_version >= "3.7" and python_full_version < "4.0.0" \
|
--hash=sha256:466e6ed1affd0866c78f245ee658d2619f74250aca5856852d86e61dba400eda
|
||||||
--hash=sha256:a45197a3c4595a496674e7e48a58f58351b6022526893264831e0d6ba463a44f \
|
django-ipware==4.0.2; python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version < "4.0.0" and python_full_version >= "3.6.0" \
|
||||||
--hash=sha256:9acdf320537ccce47ceb1d51d2a00fafbf30938152d3b22c59a3a2ead7952227
|
--hash=sha256:602a58325a4808bd19197fef2676a0b2da2df40d0ecf21be414b2ff48c72ad05 \
|
||||||
django==3.1.7; python_version >= "3.7" and python_full_version < "4.0.0" and python_version < "4.0" \
|
--hash=sha256:878dbb06a87e25550798e9ef3204ed70a200dd8b15e47dcef848cf08244f04c9
|
||||||
--hash=sha256:baf099db36ad31f970775d0be5587cc58a6256a6771a44eb795b554d45f211b8 \
|
django-redis==5.2.0; python_version >= "3.7" and python_full_version < "4.0.0" \
|
||||||
--hash=sha256:32ce792ee9b6a0cbbec340123e229ac9f765dff8c2a4ae9247a14b2ba3a365a7
|
--hash=sha256:8a99e5582c79f894168f5865c52bd921213253b7fd64d16733ae4591564465de \
|
||||||
gunicorn==20.0.4; python_version >= "3.7" and python_full_version < "4.0.0" \
|
--hash=sha256:1d037dc02b11ad7aa11f655d26dac3fb1af32630f61ef4428860a2e29ff92026
|
||||||
--hash=sha256:cd4a810dd51bf497552cf3f863b575dabd73d6ad6a91075b65936b151cbf4f9c \
|
django-yunohost-integration==0.3.0; python_version >= "3.7" and python_full_version < "4.0.0" \
|
||||||
--hash=sha256:1904bb2b8a43658807108d59c3f3d56c2b6121a701161de0ddf9ad140073c626
|
--hash=sha256:f7f8e9d55c50231bb32d3809b240d6ac718aadac1a1f471284baa1bfa6e98dff \
|
||||||
psycopg2-binary==2.8.6; python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version < "4.0.0" and python_full_version >= "3.4.0" \
|
--hash=sha256:d0e9cc91d241075613cb54b5da0879ad9b8ad3d22b84130cd7a331025650406e
|
||||||
--hash=sha256:11b9c0ebce097180129e422379b824ae21c8f2a6596b159c7659e2e5a00e1aa0 \
|
django==3.2.15; python_version >= "3.7" and python_full_version < "4.0.0" \
|
||||||
--hash=sha256:d14b140a4439d816e3b1229a4a525df917d6ea22a0771a2a78332273fd9528a4 \
|
--hash=sha256:115baf5049d5cf4163e43492cdc7139c306ed6d451e7d3571fe9612903903713 \
|
||||||
--hash=sha256:1fabed9ea2acc4efe4671b92c669a213db744d2af8a9fc5d69a8e9bc14b7a9db \
|
--hash=sha256:f71934b1a822f14a86c9ac9634053689279cd04ae69cb6ade4a59471b886582b
|
||||||
--hash=sha256:f5ab93a2cb2d8338b1674be43b442a7f544a0971da062a5da774ed40587f18f5 \
|
gunicorn==20.1.0; python_version >= "3.7" and python_full_version < "4.0.0" \
|
||||||
--hash=sha256:b4afc542c0ac0db720cf516dd20c0846f71c248d2b3d21013aa0d4ef9c71ca25 \
|
--hash=sha256:9dcc4547dbb1cb284accfb15ab5667a0e5d1881cc443e0677b4882a4067a807e \
|
||||||
--hash=sha256:e74a55f6bad0e7d3968399deb50f61f4db1926acf4a6d83beaaa7df986f48b1c \
|
--hash=sha256:e0a968b5ba15f8a328fdfd7ab1fcb5af4470c28aaf7e55df02a99bc13138e6e8
|
||||||
--hash=sha256:0deac2af1a587ae12836aa07970f5cb91964f05a7c6cdb69d8425ff4c15d4e2c \
|
importlib-metadata==4.2.0; python_version >= "3.7" and python_full_version < "4.0.0" and python_version < "3.8" \
|
||||||
--hash=sha256:ad20d2eb875aaa1ea6d0f2916949f5c08a19c74d05b16ce6ebf6d24f2c9f75d1 \
|
--hash=sha256:057e92c15bc8d9e8109738a48db0ccb31b4d9d5cfbee5a8670879a30be66304b \
|
||||||
--hash=sha256:950bc22bb56ee6ff142a2cb9ee980b571dd0912b0334aa3fe0fe3788d860bea2 \
|
--hash=sha256:b7e52a1f8dec14a75ea73e0891f3060099ca1d8e6a462a4dff11c3e119ea1b31
|
||||||
--hash=sha256:b8a3715b3c4e604bcc94c90a825cd7f5635417453b253499664f784fc4da0152 \
|
packaging==21.3; python_version >= "3.7" and python_full_version < "4.0.0" \
|
||||||
--hash=sha256:d1b4ab59e02d9008efe10ceabd0b31e79519da6fb67f7d8e8977118832d0f449 \
|
--hash=sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522 \
|
||||||
--hash=sha256:ac0c682111fbf404525dfc0f18a8b5f11be52657d4f96e9fcb75daf4f3984859 \
|
--hash=sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb
|
||||||
--hash=sha256:7d92a09b788cbb1aec325af5fcba9fed7203897bbd9269d5691bb1e3bce29550 \
|
psycopg2==2.9.3; python_version >= "3.7" and python_full_version < "4.0.0" \
|
||||||
--hash=sha256:aaa4213c862f0ef00022751161df35804127b78adf4a2755b9f991a507e425fd \
|
--hash=sha256:083707a696e5e1c330af2508d8fab36f9700b26621ccbcb538abe22e15485362 \
|
||||||
--hash=sha256:c2507d796fca339c8fb03216364cca68d87e037c1f774977c8fc377627d01c71 \
|
--hash=sha256:d3ca6421b942f60c008f81a3541e8faf6865a28d5a9b48544b0ee4f40cac7fca \
|
||||||
--hash=sha256:ee69dad2c7155756ad114c02db06002f4cded41132cc51378e57aad79cc8e4f4 \
|
--hash=sha256:9572e08b50aed176ef6d66f15a21d823bb6f6d23152d35e8451d7d2d18fdac56 \
|
||||||
--hash=sha256:e82aba2188b9ba309fd8e271702bd0d0fc9148ae3150532bbb474f4590039ffb \
|
--hash=sha256:a81e3866f99382dfe8c15a151f1ca5fde5815fde879348fe5a9884a7c092a305 \
|
||||||
--hash=sha256:d5227b229005a696cc67676e24c214740efd90b148de5733419ac9aaba3773da \
|
--hash=sha256:cb10d44e6694d763fa1078a26f7f6137d69f555a78ec85dc2ef716c37447e4b2 \
|
||||||
--hash=sha256:a0eb43a07386c3f1f1ebb4dc7aafb13f67188eab896e7397aa1ee95a9c884eb2 \
|
--hash=sha256:4295093a6ae3434d33ec6baab4ca5512a5082cc43c0505293087b8a46d108461 \
|
||||||
--hash=sha256:e1f57aa70d3f7cc6947fd88636a481638263ba04a742b4a37dd25c373e41491a \
|
--hash=sha256:34b33e0162cfcaad151f249c2649fd1030010c16f4bbc40a604c1cb77173dcf7 \
|
||||||
--hash=sha256:833709a5c66ca52f1d21d41865a637223b368c0ee76ea54ca5bad6f2526c7679 \
|
--hash=sha256:0762c27d018edbcb2d34d51596e4346c983bd27c330218c56c4dc25ef7e819bf \
|
||||||
--hash=sha256:ba28584e6bca48c59eecbf7efb1576ca214b47f05194646b081717fa628dfddf \
|
--hash=sha256:8cf3878353cc04b053822896bc4922b194792df9df2f1ad8da01fb3043602126 \
|
||||||
--hash=sha256:6a32f3a4cb2f6e1a0b15215f448e8ce2da192fd4ff35084d80d5e39da683e79b \
|
--hash=sha256:06f32425949bd5fe8f625c49f17ebb9784e1e4fe928b7cce72edc36fb68e4c0c \
|
||||||
--hash=sha256:0e4dc3d5996760104746e6cfcdb519d9d2cd27c738296525d5867ea695774e67 \
|
--hash=sha256:8e841d1bf3434da985cc5ef13e6f75c8981ced601fd70cc6bf33351b91562981
|
||||||
--hash=sha256:cec7e622ebc545dbb4564e483dd20e4e404da17ae07e06f3e780b2dacd5cee66 \
|
pyparsing==3.0.9; python_version >= "3.7" and python_full_version < "4.0.0" and python_full_version >= "3.6.8" \
|
||||||
--hash=sha256:ba381aec3a5dc29634f20692349d73f2d21f17653bda1decf0b52b11d694541f \
|
--hash=sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc \
|
||||||
--hash=sha256:a0c50db33c32594305b0ef9abc0cb7db13de7621d2cadf8392a1d9b3c437ef77 \
|
--hash=sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb
|
||||||
--hash=sha256:2dac98e85565d5688e8ab7bdea5446674a83a3945a8f416ad0110018d1501b94 \
|
pytz==2022.2.1; python_version >= "3.7" and python_full_version < "4.0.0" \
|
||||||
--hash=sha256:bd1be66dde2b82f80afb9459fc618216753f67109b859a361cf7def5c7968729 \
|
--hash=sha256:220f481bdafa09c3955dfbdddb7b57780e9a94f5127e35456a48589b9e0c0197 \
|
||||||
--hash=sha256:8cd0fb36c7412996859cb4606a35969dd01f4ea34d9812a141cd920c3b18be77 \
|
--hash=sha256:cea221417204f2d1a2aa03ddae3e867921971d0d76f14d87abb4414415bbdcf5
|
||||||
--hash=sha256:89705f45ce07b2dfa806ee84439ec67c5d9a0ef20154e0e475e2b2ed392a5b83 \
|
redis==4.3.4; python_version >= "3.7" and python_full_version < "4.0.0" \
|
||||||
--hash=sha256:42ec1035841b389e8cc3692277a0bd81cdfe0b65d575a2c8862cec7a80e62e52 \
|
--hash=sha256:a52d5694c9eb4292770084fa8c863f79367ca19884b329ab574d5cb2036b3e54 \
|
||||||
--hash=sha256:7312e931b90fe14f925729cde58022f5d034241918a5c4f9797cac62f6b3a9dd \
|
--hash=sha256:ddf27071df4adf3821c4f2ca59d67525c3a82e5f268bed97b813cb4fabf87880
|
||||||
--hash=sha256:6422f2ff0919fd720195f64ffd8f924c1395d30f9a495f31e2392c2efafb5056 \
|
sqlparse==0.4.2; python_version >= "3.7" and python_full_version < "4.0.0" \
|
||||||
--hash=sha256:15978a1fbd225583dd8cdaf37e67ccc278b5abecb4caf6b2d6b8e2b948e953f6
|
--hash=sha256:48719e356bb8b42991bdbb1e8b83223757b93789c00910a616a071910ca4a64d \
|
||||||
pytz==2021.1; python_version >= "3.7" and python_full_version < "4.0.0" \
|
--hash=sha256:0c00730c74263a94e5a9919ade150dfc3b19c574389985446148402998287dae
|
||||||
--hash=sha256:eb10ce3e7736052ed3623d49975ce333bcd712c7bb19a58b9e2089d4057d0798 \
|
typing-extensions==4.3.0; python_version >= "3.7" and python_full_version < "4.0.0" and python_version < "3.8" \
|
||||||
--hash=sha256:83a4a90894bf38e243cf052c8b58f381bfe9a7a483f6a9cab140bc7f702ac4da
|
--hash=sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02 \
|
||||||
redis==3.5.3; python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version < "4.0.0" and python_full_version >= "3.5.0" \
|
--hash=sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6
|
||||||
--hash=sha256:432b788c4530cfe16d8d943a09d40ca6c16149727e4afe8c2c9d5580c59d9f24 \
|
wrapt==1.14.1; python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version < "4.0.0" and python_full_version >= "3.5.0" \
|
||||||
--hash=sha256:0e7e0cfca8660dea8b7d5cd8c4f6c5e29e11f31158c0b0ae91a397f00e5a05a2
|
--hash=sha256:1b376b3f4896e7930f1f772ac4b064ac12598d1c38d04907e696cc4d794b43d3 \
|
||||||
sqlparse==0.4.1; python_version >= "3.7" and python_full_version < "4.0.0" \
|
--hash=sha256:903500616422a40a98a5a3c4ff4ed9d0066f3b4c951fa286018ecdf0750194ef \
|
||||||
--hash=sha256:017cde379adbd6a1f15a61873f43e8274179378e95ef3fede90b5aa64d304ed0 \
|
--hash=sha256:5a9a0d155deafd9448baff28c08e150d9b24ff010e899311ddd63c45c2445e28 \
|
||||||
--hash=sha256:0f91fd2e829c44362cbcfab3e9ae12e22badaa8a29ad5ff599f9ec109f0454e8
|
--hash=sha256:ddaea91abf8b0d13443f6dac52e89051a5063c7d014710dcb4d4abb2ff811a59 \
|
||||||
|
--hash=sha256:36f582d0c6bc99d5f39cd3ac2a9062e57f3cf606ade29a0a0d6b323462f4dd87 \
|
||||||
|
--hash=sha256:7ef58fb89674095bfc57c4069e95d7a31cfdc0939e2a579882ac7d55aadfd2a1 \
|
||||||
|
--hash=sha256:e2f83e18fe2f4c9e7db597e988f72712c0c3676d337d8b101f6758107c42425b \
|
||||||
|
--hash=sha256:ee2b1b1769f6707a8a445162ea16dddf74285c3964f605877a20e38545c3c462 \
|
||||||
|
--hash=sha256:833b58d5d0b7e5b9832869f039203389ac7cbf01765639c7309fd50ef619e0b1 \
|
||||||
|
--hash=sha256:80bb5c256f1415f747011dc3604b59bc1f91c6e7150bd7db03b19170ee06b320 \
|
||||||
|
--hash=sha256:07f7a7d0f388028b2df1d916e94bbb40624c59b48ecc6cbc232546706fac74c2 \
|
||||||
|
--hash=sha256:02b41b633c6261feff8ddd8d11c711df6842aba629fdd3da10249a53211a72c4 \
|
||||||
|
--hash=sha256:2fe803deacd09a233e4762a1adcea5db5d31e6be577a43352936179d14d90069 \
|
||||||
|
--hash=sha256:257fd78c513e0fb5cdbe058c27a0624c9884e735bbd131935fd49e9fe719d310 \
|
||||||
|
--hash=sha256:4fcc4649dc762cddacd193e6b55bc02edca674067f5f98166d7713b193932b7f \
|
||||||
|
--hash=sha256:11871514607b15cfeb87c547a49bca19fde402f32e2b1c24a632506c0a756656 \
|
||||||
|
--hash=sha256:8ad85f7f4e20964db4daadcab70b47ab05c7c1cf2a7c1e51087bfaa83831854c \
|
||||||
|
--hash=sha256:a9a52172be0b5aae932bef82a79ec0a0ce87288c7d132946d645eba03f0ad8a8 \
|
||||||
|
--hash=sha256:6d323e1554b3d22cfc03cd3243b5bb815a51f5249fdcbb86fda4bf62bab9e164 \
|
||||||
|
--hash=sha256:43ca3bbbe97af00f49efb06e352eae40434ca9d915906f77def219b88e85d907 \
|
||||||
|
--hash=sha256:6b1a564e6cb69922c7fe3a678b9f9a3c54e72b469875aa8018f18b4d1dd1adf3 \
|
||||||
|
--hash=sha256:00b6d4ea20a906c0ca56d84f93065b398ab74b927a7a3dbd470f6fc503f95dc3 \
|
||||||
|
--hash=sha256:a85d2b46be66a71bedde836d9e41859879cc54a2a04fad1191eb50c2066f6e9d \
|
||||||
|
--hash=sha256:dbcda74c67263139358f4d188ae5faae95c30929281bc6866d00573783c422b7 \
|
||||||
|
--hash=sha256:b21bb4c09ffabfa0e85e3a6b623e19b80e7acd709b9f91452b8297ace2a8ab00 \
|
||||||
|
--hash=sha256:9e0fd32e0148dd5dea6af5fee42beb949098564cc23211a88d799e434255a1f4 \
|
||||||
|
--hash=sha256:9736af4641846491aedb3c3f56b9bc5568d92b0692303b5a305301a95dfd38b1 \
|
||||||
|
--hash=sha256:5b02d65b9ccf0ef6c34cba6cf5bf2aab1bb2f49c6090bafeecc9cd81ad4ea1c1 \
|
||||||
|
--hash=sha256:21ac0156c4b089b330b7666db40feee30a5d52634cc4560e1905d6529a3897ff \
|
||||||
|
--hash=sha256:9f3e6f9e05148ff90002b884fbc2a86bd303ae847e472f44ecc06c2cd2fcdb2d \
|
||||||
|
--hash=sha256:6e743de5e9c3d1b7185870f480587b75b1cb604832e380d64f9504a0535912d1 \
|
||||||
|
--hash=sha256:d79d7d5dc8a32b7093e81e97dad755127ff77bcc899e845f41bf71747af0c569 \
|
||||||
|
--hash=sha256:81b19725065dcb43df02b37e03278c011a09e49757287dca60c5aecdd5a0b8ed \
|
||||||
|
--hash=sha256:b014c23646a467558be7da3d6b9fa409b2c567d2110599b7cf9a0c5992b3b471 \
|
||||||
|
--hash=sha256:88bd7b6bd70a5b6803c1abf6bca012f7ed963e58c68d76ee20b9d751c74a3248 \
|
||||||
|
--hash=sha256:b5901a312f4d14c59918c221323068fad0540e34324925c8475263841dbdfe68 \
|
||||||
|
--hash=sha256:d77c85fedff92cf788face9bfa3ebaa364448ebb1d765302e9af11bf449ca36d \
|
||||||
|
--hash=sha256:8d649d616e5c6a678b26d15ece345354f7c2286acd6db868e65fcc5ff7c24a77 \
|
||||||
|
--hash=sha256:7d2872609603cb35ca513d7404a94d6d608fc13211563571117046c9d2bcc3d7 \
|
||||||
|
--hash=sha256:ee6acae74a2b91865910eef5e7de37dc6895ad96fa23603d1d27ea69df545015 \
|
||||||
|
--hash=sha256:2b39d38039a1fdad98c87279b48bc5dce2c0ca0d73483b12cb72aa9609278e8a \
|
||||||
|
--hash=sha256:60db23fa423575eeb65ea430cee741acb7c26a1365d103f7b0f6ec412b893853 \
|
||||||
|
--hash=sha256:709fe01086a55cf79d20f741f39325018f4df051ef39fe921b1ebe780a66184c \
|
||||||
|
--hash=sha256:8c0ce1e99116d5ab21355d8ebe53d9460366704ea38ae4d9f6933188f327b456 \
|
||||||
|
--hash=sha256:e3fb1677c720409d5f671e39bac6c9e0e422584e5f518bfd50aa4cbbea02433f \
|
||||||
|
--hash=sha256:642c2e7a804fcf18c222e1060df25fc210b9c58db7c91416fb055897fc27e8cc \
|
||||||
|
--hash=sha256:7b7c050ae976e286906dd3f26009e117eb000fb2cf3533398c5ad9ccc86867b1 \
|
||||||
|
--hash=sha256:ef3f72c9666bba2bab70d2a8b79f2c6d2c1a42a7f7e2b0ec83bb2f9e383950af \
|
||||||
|
--hash=sha256:01c205616a89d09827986bc4e859bcabd64f5a0662a7fe95e0d359424e0e071b \
|
||||||
|
--hash=sha256:5a0f54ce2c092aaf439813735584b9537cad479575a09892b8352fea5e988dc0 \
|
||||||
|
--hash=sha256:2cf71233a0ed05ccdabe209c606fe0bac7379fdcf687f39b944420d2a09fdb57 \
|
||||||
|
--hash=sha256:aa31fdcc33fef9eb2552cbcbfee7773d5a6792c137b359e82879c101e98584c5 \
|
||||||
|
--hash=sha256:d1967f46ea8f2db647c786e78d8cc7e4313dbd1b0aca360592d8027b8508e24d \
|
||||||
|
--hash=sha256:3232822c7d98d23895ccc443bbdf57c7412c5a65996c30442ebe6ed3df335383 \
|
||||||
|
--hash=sha256:988635d122aaf2bdcef9e795435662bcd65b02f4f4c1ae37fbee7401c440b3a7 \
|
||||||
|
--hash=sha256:9cca3c2cdadb362116235fdbd411735de4328c61425b0aa9f872fd76d02c4e86 \
|
||||||
|
--hash=sha256:d52a25136894c63de15a35bc0bdc5adb4b0e173b9c0d07a2be9d3ca64a332735 \
|
||||||
|
--hash=sha256:40e7bc81c9e2b2734ea4bc1aceb8a8f0ceaac7c5299bc5d69e37c44d9081d43b \
|
||||||
|
--hash=sha256:b9b7a708dd92306328117d8c4b62e2194d00c365f18eff11a9b53c6f923b01e3 \
|
||||||
|
--hash=sha256:6a9a25751acb379b466ff6be78a315e2b439d4c94c1e99cb7266d40a537995d3 \
|
||||||
|
--hash=sha256:34aa51c45f28ba7f12accd624225e2b1e5a3a45206aa191f6f9aac931d9d56fe \
|
||||||
|
--hash=sha256:dee0ce50c6a2dd9056c20db781e9c1cfd33e77d2d569f5d1d9321c641bb903d5 \
|
||||||
|
--hash=sha256:dee60e1de1898bde3b238f18340eec6148986da0455d8ba7848d50470a7a32fb \
|
||||||
|
--hash=sha256:380a85cf89e0e69b7cfbe2ea9f765f004ff419f34194018a6827ac0e3edfed4d
|
||||||
|
zipp==3.8.1; python_version >= "3.7" and python_full_version < "4.0.0" and python_version < "3.8" \
|
||||||
|
--hash=sha256:47c40d7fe183a6f21403a199b3e4192cca5774656965b0a4988ad2f8feb5f009 \
|
||||||
|
--hash=sha256:05b45f1ee8f807d0cc928485ca40a07cb491cf092ff587c0df9cb1fd154848d2
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Please do not modify this file, it will be reset at the next update.
|
# Please do not modify this file, it will be reset at the next update.
|
||||||
# You can edit the file __FINAL_HOME_PATH__/local_settings.py and add/modify the settings you need.
|
# You can edit the file __FINALPATH__/local_settings.py and add/modify the settings you need.
|
||||||
# The parameters you add in local_settings.py will overwrite these,
|
# The parameters you add in local_settings.py will overwrite these,
|
||||||
# but you can use the options and documentation in this file to find out what can be done.
|
# but you can use the options and documentation in this file to find out what can be done.
|
||||||
|
|
||||||
|
@ -11,19 +11,21 @@
|
||||||
|
|
||||||
from pathlib import Path as __Path
|
from pathlib import Path as __Path
|
||||||
|
|
||||||
from django_yunohost_integration.secret_key import get_or_create_secret as __get_or_create_secret
|
|
||||||
from django_yunohost_integration.base_settings import * # noqa
|
from django_yunohost_integration.base_settings import * # noqa
|
||||||
|
from django_yunohost_integration.secret_key import get_or_create_secret as __get_or_create_secret
|
||||||
|
|
||||||
|
|
||||||
DEBUG = False # Don't turn DEBUG on in production!
|
# Set via config_panel.toml
|
||||||
|
DEBUG_ENABLED = '__DEBUG_ENABLED__'
|
||||||
|
DEBUG = bool(int(DEBUG_ENABLED))
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
FINAL_HOME_PATH = __Path('__FINAL_HOME_PATH__') # /opt/yunohost/$app
|
FINALPATH = __Path('__FINALPATH__') # /opt/yunohost/$app
|
||||||
assert FINAL_HOME_PATH.is_dir(), f'Directory not exists: {FINAL_HOME_PATH}'
|
assert FINALPATH.is_dir(), f'Directory not exists: {FINALPATH}'
|
||||||
|
|
||||||
FINAL_WWW_PATH = __Path('__FINAL_WWW_PATH__') # /var/www/$app
|
PUBLIC_PATH = __Path('__PUBLIC_PATH__') # /var/www/$app
|
||||||
assert FINAL_WWW_PATH.is_dir(), f'Directory not exists: {FINAL_WWW_PATH}'
|
assert PUBLIC_PATH.is_dir(), f'Directory not exists: {PUBLIC_PATH}'
|
||||||
|
|
||||||
LOG_FILE = __Path('__LOG_FILE__') # /var/log/$app/django_example_ynh.log
|
LOG_FILE = __Path('__LOG_FILE__') # /var/log/$app/django_example_ynh.log
|
||||||
assert LOG_FILE.is_file(), f'File not exists: {LOG_FILE}'
|
assert LOG_FILE.is_file(), f'File not exists: {LOG_FILE}'
|
||||||
|
@ -36,7 +38,7 @@ PATH_URL = PATH_URL.strip('/')
|
||||||
# Function that will be called to finalize a user profile:
|
# Function that will be called to finalize a user profile:
|
||||||
YNH_SETUP_USER = 'setup_user.setup_project_user'
|
YNH_SETUP_USER = 'setup_user.setup_project_user'
|
||||||
|
|
||||||
SECRET_KEY = __get_or_create_secret(FINAL_HOME_PATH / 'secret.txt') # /opt/yunohost/$app/secret.txt
|
SECRET_KEY = __get_or_create_secret(FINALPATH / 'secret.txt') # /opt/yunohost/$app/secret.txt
|
||||||
|
|
||||||
# INSTALLED_APPS.append('<insert-your-app-here>')
|
# INSTALLED_APPS.append('<insert-your-app-here>')
|
||||||
|
|
||||||
|
@ -50,8 +52,8 @@ MANAGERS = ADMINS
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.postgresql',
|
'ENGINE': 'django.db.backends.postgresql',
|
||||||
'NAME': '__APP__',
|
'NAME': '__DB_NAME__',
|
||||||
'USER': '__APP__',
|
'USER': '__DB_USER__',
|
||||||
'PASSWORD': '__DB_PWD__',
|
'PASSWORD': '__DB_PWD__',
|
||||||
'HOST': '127.0.0.1',
|
'HOST': '127.0.0.1',
|
||||||
'PORT': '5432', # Default Postgres Port
|
'PORT': '5432', # Default Postgres Port
|
||||||
|
@ -106,9 +108,8 @@ else:
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
MEDIA_URL = '/media/'
|
MEDIA_URL = '/media/'
|
||||||
|
|
||||||
STATIC_ROOT = str(FINAL_WWW_PATH / 'static')
|
STATIC_ROOT = str(PUBLIC_PATH / 'static')
|
||||||
MEDIA_ROOT = str(FINAL_WWW_PATH / 'media')
|
MEDIA_ROOT = str(PUBLIC_PATH / 'media')
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -139,8 +140,16 @@ LOGGING = {
|
||||||
'': {'handlers': ['log_file', 'mail_admins'], 'level': 'INFO', 'propagate': False},
|
'': {'handlers': ['log_file', 'mail_admins'], 'level': 'INFO', 'propagate': False},
|
||||||
'django': {'handlers': ['log_file', 'mail_admins'], 'level': 'INFO', 'propagate': False},
|
'django': {'handlers': ['log_file', 'mail_admins'], 'level': 'INFO', 'propagate': False},
|
||||||
'axes': {'handlers': ['log_file', 'mail_admins'], 'level': 'WARNING', 'propagate': False},
|
'axes': {'handlers': ['log_file', 'mail_admins'], 'level': 'WARNING', 'propagate': False},
|
||||||
'django_tools': {'handlers': ['log_file', 'mail_admins'], 'level': 'INFO', 'propagate': False},
|
'django_tools': {
|
||||||
'django_yunohost_integration': {'handlers': ['log_file', 'mail_admins'], 'level': 'INFO', 'propagate': False},
|
'handlers': ['log_file', 'mail_admins'],
|
||||||
|
'level': 'INFO',
|
||||||
|
'propagate': False,
|
||||||
|
},
|
||||||
|
'django_yunohost_integration': {
|
||||||
|
'handlers': ['log_file', 'mail_admins'],
|
||||||
|
'level': 'INFO',
|
||||||
|
'propagate': False,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
33
conf/urls.py
33
conf/urls.py
|
@ -1,3 +1,19 @@
|
||||||
|
"""
|
||||||
|
urls.py
|
||||||
|
~~~~~~~
|
||||||
|
|
||||||
|
Note: This is not a good example how your urls.py can look like.
|
||||||
|
Because this setup is just an example without a real Python application.
|
||||||
|
|
||||||
|
Look at real examples, here:
|
||||||
|
|
||||||
|
* https://github.com/YunoHost-Apps/django-fritzconnection_ynh/blob/master/conf/urls.py
|
||||||
|
* https://github.com/YunoHost-Apps/django-for-runners_ynh/blob/testing/conf/urls.py
|
||||||
|
* https://github.com/YunoHost-Apps/pyinventory_ynh/blob/testing/conf/urls.py
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
@ -5,9 +21,16 @@ from django.urls import path
|
||||||
from django_yunohost_integration.views import request_media_debug_view
|
from django_yunohost_integration.views import request_media_debug_view
|
||||||
|
|
||||||
|
|
||||||
# settings.PATH_URL is the $YNH_APP_ARG_PATH
|
if settings.PATH_URL:
|
||||||
# Prefix all urls with "PATH_URL":
|
# settings.PATH_URL is the $YNH_APP_ARG_PATH
|
||||||
urlpatterns = [
|
# Prefix all urls with "PATH_URL":
|
||||||
path(f'{settings.PATH_URL}/', admin.site.urls),
|
urlpatterns = [
|
||||||
path(f'{settings.PATH_URL}/debug/', request_media_debug_view),
|
path(f'{settings.PATH_URL}/debug/', request_media_debug_view),
|
||||||
]
|
path(f'{settings.PATH_URL}/', admin.site.urls),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
# Installed to domain root, without a path prefix
|
||||||
|
urlpatterns = [
|
||||||
|
path('/debug/', request_media_debug_view),
|
||||||
|
path('/', admin.site.urls),
|
||||||
|
]
|
||||||
|
|
16
config_panel.toml
Normal file
16
config_panel.toml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
version = "1.0"
|
||||||
|
|
||||||
|
[main]
|
||||||
|
name = "django_example_ynh configuration"
|
||||||
|
services = ["__APP__"]
|
||||||
|
|
||||||
|
[main.config]
|
||||||
|
name = "Configuration Options"
|
||||||
|
|
||||||
|
[main.config.debug_enabled]
|
||||||
|
ask = "Enable DEBUG mode"
|
||||||
|
type = "boolean"
|
||||||
|
yes = "1"
|
||||||
|
no = "0"
|
||||||
|
help = "Should be never enabled in production!"
|
||||||
|
bind = "debug_enabled:__FINALPATH__/settings.py"
|
9
doc/DESCRIPTION.md
Normal file
9
doc/DESCRIPTION.md
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[](https://github.com/YunoHost-Apps/django_example_ynh/actions/workflows/pytest.yml) [](https://github.com/YunoHost-Apps/django_example_ynh/actions/workflows/package_linter.yml)
|
||||||
|
|
||||||
|
Demo [YunoHost Application](https://install-app.yunohost.org/?app=django_example_ynh) to demonstrate the integration of a Django project under YunoHost.
|
||||||
|
|
||||||
|
[](https://dash.yunohost.org/appci/app/django_example_ynh)  
|
||||||
|
[](https://install-app.yunohost.org/?app=django_example_ynh)
|
||||||
|
|
||||||
|
|
||||||
|
Pull requests welcome ;)
|
152
doc/DISCLAIMER.md
Normal file
152
doc/DISCLAIMER.md
Normal file
|
@ -0,0 +1,152 @@
|
||||||
|
## local test
|
||||||
|
|
||||||
|
For quicker developing of django_example_ynh in the context of YunoHost app,
|
||||||
|
it's possible to run the Django developer server with the settings
|
||||||
|
and urls made for YunoHost installation.
|
||||||
|
|
||||||
|
e.g.:
|
||||||
|
```bash
|
||||||
|
~$ git clone https://github.com/YunoHost-Apps/django_example_ynh.git
|
||||||
|
~$ cd django_example_ynh/
|
||||||
|
~/django_example_ynh$ make
|
||||||
|
install-poetry install or update poetry
|
||||||
|
install install project via poetry
|
||||||
|
update update the sources and installation and generate "conf/requirements.txt"
|
||||||
|
lint Run code formatters and linter
|
||||||
|
fix-code-style Fix code formatting
|
||||||
|
tox-listenvs List all tox test environments
|
||||||
|
tox Run pytest via tox with all environments
|
||||||
|
pytest Run pytest
|
||||||
|
publish Release new version to PyPi
|
||||||
|
local-test Run local_test.py to run the project locally
|
||||||
|
local-diff-settings Run "manage.py diffsettings" with local test
|
||||||
|
|
||||||
|
~/django_example_ynh$ make install-poetry
|
||||||
|
~/django_example_ynh$ make install
|
||||||
|
~/django_example_ynh$ make local-test
|
||||||
|
```
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
* SQlite database will be used
|
||||||
|
* A super user with username `test` and password `test` is created
|
||||||
|
* The page is available under `http://127.0.0.1:8000/app_path/`
|
||||||
|
|
||||||
|
|
||||||
|
## history
|
||||||
|
|
||||||
|
* [compare v0.1.5...master](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.2.0...master) **dev**
|
||||||
|
* tbc
|
||||||
|
* [v0.2.0 - 15.09.2021](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.1.5...v0.2.0)
|
||||||
|
* rename/split `django_example_ynh` into:
|
||||||
|
* [django_yunohost_integration](https://github.com/jedie/django_yunohost_integration) - Python package with the glue code to integrate a Django project with YunoHost
|
||||||
|
* [django_example_ynh](https://github.com/YunoHost-Apps/django_example_ynh) - Demo YunoHost App to demonstrate the integration of a Django project under YunoHost
|
||||||
|
* [v0.1.5 - 19.01.2021](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.1.4...v0.1.5)
|
||||||
|
* Make some deps `gunicorn`, `psycopg2-binary`, `django-redis`, `django-axes` optional
|
||||||
|
* [v0.1.4 - 08.01.2021](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.1.3...v0.1.4)
|
||||||
|
* Bugfix [CSRF verification failed on POST requests #7](https://github.com/YunoHost-Apps/django_example_ynh/issues/7)
|
||||||
|
* [v0.1.3 - 08.01.2021](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.1.2...v0.1.3)
|
||||||
|
* set "DEBUG = True" in local_test (so static files are served and auth works)
|
||||||
|
* Bugfixes and cleanups
|
||||||
|
* [v0.1.2 - 29.12.2020](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.1.1...v0.1.2)
|
||||||
|
* Bugfixes
|
||||||
|
* [v0.1.1 - 29.12.2020](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.1.0...v0.1.1)
|
||||||
|
* Refactor "create_superuser" to a manage command, useable via "django_example_ynh" in `INSTALLED_APPS`
|
||||||
|
* Generate "conf/requirements.txt" and use this file for install
|
||||||
|
* rename own settings and urls (in `/conf/`)
|
||||||
|
* [v0.1.0 - 28.12.2020](https://github.com/YunoHost-Apps/django_example_ynh/compare/f578f14...v0.1.0)
|
||||||
|
* first working state
|
||||||
|
* [23.12.2020](https://github.com/YunoHost-Apps/django_example_ynh/commit/f578f144a3a6d11d7044597c37d550d29c247773)
|
||||||
|
* init the project
|
||||||
|
|
||||||
|
|
||||||
|
## Links
|
||||||
|
|
||||||
|
* Report a bug about this package: https://github.com/YunoHost-Apps/django_example_ynh
|
||||||
|
* YunoHost website: https://yunohost.org/
|
||||||
|
* PyPi package: https://pypi.org/project/django-ynh/
|
||||||
|
|
||||||
|
These projects used `django_example_ynh`:
|
||||||
|
|
||||||
|
* https://github.com/YunoHost-Apps/django_example_ynh
|
||||||
|
* https://github.com/YunoHost-Apps/django-for-runners_ynh
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Developer info
|
||||||
|
|
||||||
|
The App project will be stored under `__FINALPATH__` (e.g.: `/opt/yunohost/$app`) that's Django's `settings.FINALPATH`
|
||||||
|
"static" / "media" files to serve via nginx are under `__PUBLIC_PATH__` (e.g.: `/var/www/$app`) that's `settings.PUBLIC_PATH`
|
||||||
|
|
||||||
|
## package installation / debugging
|
||||||
|
|
||||||
|
This app is not in YunoHost app catalog. Test install, e.g.:
|
||||||
|
```bash
|
||||||
|
~# git clone https://github.com/YunoHost-Apps/django_example_ynh.git
|
||||||
|
~# yunohost app install django_example_ynh/ -f
|
||||||
|
```
|
||||||
|
To update:
|
||||||
|
```bash
|
||||||
|
~# cd django_example_ynh
|
||||||
|
~/django_example_ynh# git fetch && git reset --hard origin/testing
|
||||||
|
~/django_example_ynh# yunohost app upgrade django_example_ynh -u . -F
|
||||||
|
```
|
||||||
|
|
||||||
|
To remove call e.g.:
|
||||||
|
```bash
|
||||||
|
sudo yunohost app remove django_example_ynh
|
||||||
|
```
|
||||||
|
|
||||||
|
Backup / remove / restore cycle, e.g.:
|
||||||
|
```bash
|
||||||
|
yunohost backup create --apps django_example_ynh
|
||||||
|
yunohost backup list
|
||||||
|
archives:
|
||||||
|
- django_example_ynh-pre-upgrade1
|
||||||
|
- 20201223-163434
|
||||||
|
yunohost app remove django_example_ynh
|
||||||
|
yunohost backup restore 20201223-163434 --apps django_example_ynh
|
||||||
|
```
|
||||||
|
|
||||||
|
Debug the installation, e.g.:
|
||||||
|
```bash
|
||||||
|
root@yunohost:~# cat /etc/yunohost/apps/django_example_ynh/settings.yml
|
||||||
|
...
|
||||||
|
|
||||||
|
root@yunohost:~# ls -la /var/www/django_example_ynh/
|
||||||
|
total 18
|
||||||
|
drwxr-xr-x 4 root root 4 Dec 8 08:36 .
|
||||||
|
drwxr-xr-x 6 root root 6 Dec 8 08:36 ..
|
||||||
|
drwxr-xr-x 2 root root 2 Dec 8 08:36 media
|
||||||
|
drwxr-xr-x 7 root root 8 Dec 8 08:40 static
|
||||||
|
|
||||||
|
root@yunohost:~# ls -la /opt/yunohost/django_example_ynh/
|
||||||
|
total 58
|
||||||
|
drwxr-xr-x 5 django_example_ynh django_example_ynh 11 Dec 8 08:39 .
|
||||||
|
drwxr-xr-x 3 root root 3 Dec 8 08:36 ..
|
||||||
|
-rw-r--r-- 1 django_example_ynh django_example_ynh 460 Dec 8 08:39 gunicorn.conf.py
|
||||||
|
-rw-r--r-- 1 django_example_ynh django_example_ynh 0 Dec 8 08:39 local_settings.py
|
||||||
|
-rwxr-xr-x 1 django_example_ynh django_example_ynh 274 Dec 8 08:39 manage.py
|
||||||
|
-rw-r--r-- 1 django_example_ynh django_example_ynh 171 Dec 8 08:39 secret.txt
|
||||||
|
drwxr-xr-x 6 django_example_ynh django_example_ynh 6 Dec 8 08:37 venv
|
||||||
|
-rw-r--r-- 1 django_example_ynh django_example_ynh 115 Dec 8 08:39 wsgi.py
|
||||||
|
-rw-r--r-- 1 django_example_ynh django_example_ynh 4737 Dec 8 08:39 django_example_ynh_demo_settings.py
|
||||||
|
|
||||||
|
root@yunohost:~# cd /opt/yunohost/django_example_ynh/
|
||||||
|
root@yunohost:/opt/yunohost/django_example_ynh# source venv/bin/activate
|
||||||
|
(venv) root@yunohost:/opt/yunohost/django_example_ynh# ./manage.py check
|
||||||
|
django_example_ynh v0.8.2 (Django v2.2.17)
|
||||||
|
DJANGO_SETTINGS_MODULE='django_example_ynh_demo_settings'
|
||||||
|
PROJECT_PATH:/opt/yunohost/django_example_ynh/venv/lib/python3.7/site-packages
|
||||||
|
BASE_PATH:/opt/yunohost/django_example_ynh
|
||||||
|
System check identified no issues (0 silenced).
|
||||||
|
|
||||||
|
root@yunohost:~# tail -f /var/log/django_example_ynh/django_example_ynh.log
|
||||||
|
root@yunohost:~# cat /etc/systemd/system/systemd.service
|
||||||
|
...
|
||||||
|
|
||||||
|
root@yunohost:~# systemctl reload-or-restart django_example_ynh
|
||||||
|
root@yunohost:~# journalctl --unit=django_example_ynh --follow
|
||||||
|
```
|
||||||
|
|
||||||
|
|
0
doc/screenshots/.gitkeep
Normal file
0
doc/screenshots/.gitkeep
Normal file
|
@ -22,6 +22,9 @@ def main():
|
||||||
django_settings_path=BASE_PATH / 'conf' / 'settings.py',
|
django_settings_path=BASE_PATH / 'conf' / 'settings.py',
|
||||||
destination=BASE_PATH / 'local_test',
|
destination=BASE_PATH / 'local_test',
|
||||||
runserver=True,
|
runserver=True,
|
||||||
|
extra_replacements={
|
||||||
|
'__DEBUG_ENABLED__': '1',
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,17 @@
|
||||||
"id": "django_example_ynh",
|
"id": "django_example_ynh",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Demo YunoHost Application to demonstrate the integration of a Django project under YunoHost."
|
"en": "Demo YunoHost Application to demonstrate the integration of a Django project under YunoHost via https://github.com/YunoHost-Apps/django_yunohost_integration"
|
||||||
},
|
},
|
||||||
"version": "v0.2.0.alpha0~ynh1",
|
"version": "0.3.0~ynh1",
|
||||||
"url": "https://github.com/YunoHost-Apps/django_example_ynh",
|
"url": "https://github.com/YunoHost-Apps/django_example_ynh",
|
||||||
|
"upstream": {
|
||||||
|
"license": "GPL-3.0",
|
||||||
|
"website": "https://github.com/YunoHost-Apps/django_example_ynh",
|
||||||
|
"admindoc": "https://github.com/YunoHost-Apps/django_example_ynh",
|
||||||
|
"userdoc": "https://github.com/YunoHost-Apps/django_example_ynh",
|
||||||
|
"code": "https://github.com/YunoHost-Apps/django_example_ynh"
|
||||||
|
},
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "Jens Diemer",
|
"name": "Jens Diemer",
|
||||||
|
@ -14,49 +21,31 @@
|
||||||
},
|
},
|
||||||
"previous_maintainers": [],
|
"previous_maintainers": [],
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 4.0"
|
"yunohost": ">= 4.3"
|
||||||
},
|
},
|
||||||
"multi_instance": true,
|
"multi_instance": true,
|
||||||
"services": [
|
"services": [
|
||||||
"nginx"
|
"nginx", "postgresql", "redis"
|
||||||
],
|
],
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install" : [
|
"install" : [
|
||||||
{
|
{
|
||||||
"name": "domain",
|
"name": "domain",
|
||||||
"type": "domain",
|
"type": "domain"
|
||||||
"ask": {
|
|
||||||
"en": "Choose a domain for PyInventory",
|
|
||||||
"fr": "Choisissez un domaine pour PyInventory"
|
|
||||||
},
|
|
||||||
"example": "domain.org"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "path",
|
"name": "path",
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"ask": {
|
|
||||||
"en": "Choose a path for PyInventory",
|
|
||||||
"fr": "Choisissez un chemin pour PyInventory"
|
|
||||||
},
|
|
||||||
"example": "/django_example_ynh",
|
"example": "/django_example_ynh",
|
||||||
"default": "/django_example_ynh"
|
"default": "/django_example_ynh"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "admin",
|
"name": "admin",
|
||||||
"type": "user",
|
"type": "user"
|
||||||
"ask": {
|
|
||||||
"en": "Choose an admin user for PyInventory",
|
|
||||||
"fr": "Choisissez l'administrateur pour PyInventory"
|
|
||||||
},
|
|
||||||
"example": "johndoe"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "is_public",
|
"name": "is_public",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"ask": {
|
|
||||||
"en": "Should PyInventory be public accessible?",
|
|
||||||
"fr": "PyInventory doit-il être accessible au public ?"
|
|
||||||
},
|
|
||||||
"help": {
|
"help": {
|
||||||
"en": "Any YunoHost user and anonymous people from the web will be able to access the application",
|
"en": "Any YunoHost user and anonymous people from the web will be able to access the application",
|
||||||
"fr": "Tout utilisateur YunoHost et les personnes anonymes pourront accéder à l'application"
|
"fr": "Tout utilisateur YunoHost et les personnes anonymes pourront accéder à l'application"
|
||||||
|
|
990
poetry.lock
generated
990
poetry.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -1,14 +1,17 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "django_example_ynh"
|
name = "django_example_ynh"
|
||||||
version = "v0.2.0"
|
version = "0.3.0"
|
||||||
description = "Demo YunoHost Application to demonstrate the integration of a Django project under YunoHost."
|
description = "Demo YunoHost Application to demonstrate the integration of a Django project under YunoHost."
|
||||||
authors = ["JensDiemer <git@jensdiemer.de>"]
|
authors = ["JensDiemer <git@jensdiemer.de>"]
|
||||||
license = "GPL"
|
license = "GPL"
|
||||||
homepage = "https://github.com/YunoHost-Apps/django_example_ynh"
|
homepage = "https://github.com/YunoHost-Apps/django_example_ynh"
|
||||||
|
|
||||||
|
[tool.poetry.urls]
|
||||||
|
"Bug Tracker" = "https://github.com/YunoHost-Apps/django_example_ynh/issues"
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = ">=3.7,<4.0.0"
|
python = ">=3.7,<4.0.0" # TODO: Update to >=3.8 after YunoHost updates to Bullseye
|
||||||
django_yunohost_integration = {version = "*", extras = ["ynh"]}
|
django_yunohost_integration = {version = ">=0.3.0", extras = ["ynh"]}
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
bx_py_utils = "*" # https://github.com/boxine/bx_py_utils
|
bx_py_utils = "*" # https://github.com/boxine/bx_py_utils
|
||||||
|
@ -17,37 +20,50 @@ tox = "*"
|
||||||
pytest = "*"
|
pytest = "*"
|
||||||
pytest-cov = "*"
|
pytest-cov = "*"
|
||||||
pytest-django = "*"
|
pytest-django = "*"
|
||||||
|
pytest-darker = "*" # https://github.com/akaihola/pytest-darker
|
||||||
coveralls = "*"
|
coveralls = "*"
|
||||||
isort = "*"
|
isort = "*"
|
||||||
flake8 = "*"
|
flake8 = "*"
|
||||||
flynt = "*"
|
|
||||||
black = "*"
|
|
||||||
pyupgrade = "*"
|
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core>=1.0.0"]
|
requires = ["poetry-core>=1.0.0"]
|
||||||
build-backend = "poetry.core.masonry.api"
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
|
||||||
|
|
||||||
|
[tool.darker]
|
||||||
|
src = ['.']
|
||||||
|
revision = "origin/master..."
|
||||||
|
line_length = 100
|
||||||
|
verbose = true
|
||||||
|
skip_string_normalization = true
|
||||||
|
diff = false
|
||||||
|
check = false
|
||||||
|
stdout = false
|
||||||
|
isort = true
|
||||||
|
lint = [
|
||||||
|
"flake8",
|
||||||
|
]
|
||||||
|
log_level = "INFO"
|
||||||
|
|
||||||
|
|
||||||
|
[tool.flynt]
|
||||||
|
line_length = 100
|
||||||
|
|
||||||
|
|
||||||
[tool.isort]
|
[tool.isort]
|
||||||
# https://pycqa.github.io/isort/docs/configuration/config_files/#pyprojecttoml-preferred-format
|
# https://pycqa.github.io/isort/docs/configuration/config_files/#pyprojecttoml-preferred-format
|
||||||
atomic=true
|
atomic=true
|
||||||
line_length=120
|
profile='black'
|
||||||
case_sensitive=false
|
|
||||||
skip_glob=["*/htmlcov/*","*/migrations/*"]
|
skip_glob=["*/htmlcov/*","*/migrations/*"]
|
||||||
multi_line_output=3
|
known_first_party=['django_yunohost_integration']
|
||||||
include_trailing_comma=true
|
line_length=100
|
||||||
known_first_party=[]
|
|
||||||
no_lines_before="LOCALFOLDER"
|
|
||||||
default_section="THIRDPARTY"
|
|
||||||
sections=["FUTURE","STDLIB","THIRDPARTY","FIRSTPARTY","LOCALFOLDER"]
|
|
||||||
lines_after_imports=2
|
lines_after_imports=2
|
||||||
|
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
# https://docs.pytest.org/en/latest/customize.html#pyproject-toml
|
# https://docs.pytest.org/en/latest/customize.html#pyproject-toml
|
||||||
minversion = "6.0"
|
minversion = "6.0"
|
||||||
norecursedirs = ".* .git __pycache__ conf coverage* dist htmlcov"
|
norecursedirs = ".* .git __pycache__ conf local_test coverage* dist htmlcov"
|
||||||
# sometimes helpfull "addopts" arguments:
|
# sometimes helpfull "addopts" arguments:
|
||||||
# -vv
|
# -vv
|
||||||
# --verbose
|
# --verbose
|
||||||
|
@ -56,7 +72,6 @@ norecursedirs = ".* .git __pycache__ conf coverage* dist htmlcov"
|
||||||
# --full-trace
|
# --full-trace
|
||||||
# -p no:warnings
|
# -p no:warnings
|
||||||
addopts = """
|
addopts = """
|
||||||
--import-mode=importlib
|
|
||||||
--reuse-db
|
--reuse-db
|
||||||
--nomigrations
|
--nomigrations
|
||||||
--cov=.
|
--cov=.
|
||||||
|
@ -65,19 +80,23 @@ addopts = """
|
||||||
--cov-report xml
|
--cov-report xml
|
||||||
--no-cov-on-fail
|
--no-cov-on-fail
|
||||||
--showlocals
|
--showlocals
|
||||||
|
--darker
|
||||||
--doctest-modules
|
--doctest-modules
|
||||||
--failed-first
|
--failed-first
|
||||||
--last-failed-no-failures all
|
|
||||||
--new-first
|
--new-first
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
[tool.coverage.run]
|
||||||
|
omit = [".*"]
|
||||||
|
|
||||||
|
|
||||||
[tool.tox]
|
[tool.tox]
|
||||||
# https://tox.readthedocs.io/en/latest/example/basic.html#pyproject-toml-tox-legacy-ini
|
# https://tox.readthedocs.io/en/latest/example/basic.html#pyproject-toml-tox-legacy-ini
|
||||||
legacy_tox_ini = """
|
legacy_tox_ini = """
|
||||||
[tox]
|
[tox]
|
||||||
isolated_build = True
|
isolated_build = True
|
||||||
envlist = py39,py38,py37
|
envlist = py{37,38,39,310}
|
||||||
skip_missing_interpreters = True
|
skip_missing_interpreters = True
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
"""
|
|
||||||
Run pytest against local test creation
|
|
||||||
"""
|
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
from django_yunohost_integration.pytest_helper import run_pytest
|
|
||||||
except ImportError as err:
|
|
||||||
raise ImportError('Did you forget to activate a virtual environment?') from err
|
|
||||||
|
|
||||||
|
|
||||||
BASE_PATH = Path(__file__).parent
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
run_pytest(
|
|
||||||
django_settings_path=BASE_PATH / 'conf' / 'settings.py',
|
|
||||||
destination=BASE_PATH / 'local_test',
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
|
@ -11,6 +11,13 @@ admin=$YNH_APP_ARG_ADMIN
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ARGUMENTS FROM CONFIG PANEL
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# 'debug_enabled' -> '__DEBUG_ENABLED__' -> settings.DEBUG
|
||||||
|
debug_enabled="0"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SET CONSTANTS
|
# SET CONSTANTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -20,6 +27,8 @@ final_path=/opt/yunohost/$app
|
||||||
log_path=/var/log/$app
|
log_path=/var/log/$app
|
||||||
log_file="${log_path}/django_example_ynh.log"
|
log_file="${log_path}/django_example_ynh.log"
|
||||||
|
|
||||||
|
adminmail=$(ynh_user_get_info --username=$admin --key=mail)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -25,7 +25,6 @@ new_path=$YNH_APP_NEW_PATH
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
admin=$(ynh_app_setting_get --app="$app" --key=admin)
|
admin=$(ynh_app_setting_get --app="$app" --key=admin)
|
||||||
is_public=$(ynh_app_setting_get --app="$app" --key=is_public)
|
|
||||||
public_path=$(ynh_app_setting_get --app="$app" --key=public_path)
|
public_path=$(ynh_app_setting_get --app="$app" --key=public_path)
|
||||||
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
log_path=$(ynh_app_setting_get --app="$app" --key=log_path)
|
log_path=$(ynh_app_setting_get --app="$app" --key=log_path)
|
||||||
|
@ -113,29 +112,9 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY SETTINGS
|
# MODIFY SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Modify PyInventory's config file..."
|
ynh_script_progression --message="Modify django-fmd's config file..."
|
||||||
|
|
||||||
# save old settings file
|
ynh_add_config --template="settings.py" --destination="$final_path/settings.py"
|
||||||
settings="$final_path/settings.py"
|
|
||||||
ynh_backup_if_checksum_is_different --file="$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"
|
|
||||||
ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__ADMINMAIL__" --replace_string="$admin_mail" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__FINAL_HOME_PATH__" --replace_string="$final_path" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__FINAL_WWW_PATH__" --replace_string="$public_path" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__LOG_FILE__" --replace_string="$log_file" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$settings"
|
|
||||||
|
|
||||||
# Difference to install/upgrade scripts: Use $new_domain and $new_path here:
|
|
||||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$new_domain" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__PATH_URL__" --replace_string="$new_path" --target_file="$settings"
|
|
||||||
|
|
||||||
# Recalculate and store the config file checksum into the app settings
|
|
||||||
ynh_store_file_checksum --file="$settings"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
|
|
110
scripts/install
110
scripts/install
|
@ -40,7 +40,6 @@ touch "${log_file}"
|
||||||
ynh_script_progression --message="Storing installation settings..."
|
ynh_script_progression --message="Storing installation settings..."
|
||||||
|
|
||||||
ynh_app_setting_set --app="$app" --key=admin --value="$admin"
|
ynh_app_setting_set --app="$app" --key=admin --value="$admin"
|
||||||
ynh_app_setting_set --app="$app" --key=is_public --value="$is_public"
|
|
||||||
ynh_app_setting_set --app="$app" --key=public_path --value="$public_path"
|
ynh_app_setting_set --app="$app" --key=public_path --value="$public_path"
|
||||||
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
|
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
|
||||||
ynh_app_setting_set --app="$app" --key=log_path --value="$log_file"
|
ynh_app_setting_set --app="$app" --key=log_path --value="$log_file"
|
||||||
|
@ -51,19 +50,25 @@ ynh_app_setting_set --app="$app" --key=path --value="$path_url"
|
||||||
# Find a free port
|
# Find a free port
|
||||||
port=$(ynh_find_port --port=8000)
|
port=$(ynh_find_port --port=8000)
|
||||||
# Set port as application setting
|
# Set port as application setting
|
||||||
# https://github.com/YunoHost/yunohost/blob/dev/data/helpers.d/setting
|
# https://yunohost.org/en/contribute/packaging_apps/helpers
|
||||||
|
# https://github.com/YunoHost/yunohost/blob/dev/helpers/setting
|
||||||
ynh_app_setting_set --app="$app" --key=port --value="$port"
|
ynh_app_setting_set --app="$app" --key=port --value="$port"
|
||||||
|
|
||||||
db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
|
db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
|
||||||
admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
|
admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
|
||||||
|
|
||||||
redis_db=$(ynh_redis_get_free_db)
|
redis_db=$(ynh_redis_get_free_db)
|
||||||
|
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
|
||||||
|
|
||||||
|
# Always deactivate settings.DEBUG:
|
||||||
|
ynh_app_setting_set --app="$app" --key=debug_enabled --value="$debug_enabled"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..." --weight=40
|
ynh_script_progression --message="Installing dependencies..." --weight=20
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
|
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
|
|
||||||
|
@ -87,7 +92,8 @@ ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name"
|
||||||
ynh_script_progression --message="Configuring nginx web server..."
|
ynh_script_progression --message="Configuring nginx web server..."
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
# https://github.com/YunoHost/yunohost/blob/dev/data/helpers.d/nginx
|
# https://yunohost.org/en/contribute/packaging_apps/helpers
|
||||||
|
# https://github.com/YunoHost/yunohost/blob/dev/helpers/nginx
|
||||||
ynh_add_nginx_config "public_path" "port"
|
ynh_add_nginx_config "public_path" "port"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -99,21 +105,32 @@ ynh_script_progression --message="Configuring system user..."
|
||||||
ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell
|
ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PIP INSTALLATION
|
# PYTHON VIRTUALENV
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Install project via pip..." --weight=80
|
ynh_script_progression --message="Create Python virtualenv..." --weight=5
|
||||||
|
|
||||||
|
# Always recreate everything fresh with current python version
|
||||||
|
ynh_secure_remove "${final_path}/venv"
|
||||||
|
|
||||||
|
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
|
||||||
|
python3 -m venv --without-pip "${final_path}/venv"
|
||||||
|
|
||||||
python3 -m venv "${final_path}/venv"
|
|
||||||
cp ../conf/requirements.txt "$final_path/requirements.txt"
|
cp ../conf/requirements.txt "$final_path/requirements.txt"
|
||||||
chown -R "$app:" "$final_path"
|
chown -R "$app:" "$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# PIP INSTALLATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Install project via pip..." --weight=45
|
||||||
|
|
||||||
#run source in a 'sub shell'
|
#run source in a 'sub shell'
|
||||||
(
|
(
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "${final_path}/venv/bin/activate"
|
source "${final_path}/venv/bin/activate"
|
||||||
set -o nounset
|
set -o nounset
|
||||||
ynh_exec_as $app $final_path/venv/bin/pip install --upgrade pip
|
ynh_exec_as $app $final_path/venv/bin/python3 -m ensurepip
|
||||||
ynh_exec_as $app $final_path/venv/bin/pip install -r "$final_path/requirements.txt"
|
ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade wheel pip setuptools
|
||||||
|
ynh_exec_as $app $final_path/venv/bin/pip3 install --no-deps -r "$final_path/requirements.txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -121,39 +138,15 @@ chown -R "$app:" "$final_path"
|
||||||
# ================================================
|
# ================================================
|
||||||
ynh_script_progression --message="Create project configuration files..."
|
ynh_script_progression --message="Create project configuration files..."
|
||||||
|
|
||||||
gunicorn_conf="$final_path/gunicorn.conf.py"
|
ynh_add_config --template="gunicorn.conf.py" --destination="$final_path/gunicorn.conf.py"
|
||||||
cp "../conf/gunicorn.conf.py" "$gunicorn_conf"
|
|
||||||
ynh_replace_string --match_string="__FINAL_HOME_PATH__" --replace_string="$final_path" --target_file="$gunicorn_conf"
|
|
||||||
ynh_replace_string --match_string="__LOG_FILE__" --replace_string="$log_file" --target_file="$gunicorn_conf"
|
|
||||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$gunicorn_conf"
|
|
||||||
ynh_store_file_checksum --file="$gunicorn_conf"
|
|
||||||
|
|
||||||
cp ../conf/manage.py "$final_path/manage.py"
|
ynh_add_config --template="manage.py" --destination="$final_path/manage.py"
|
||||||
chmod +x "$final_path/manage.py"
|
chmod +x "$final_path/manage.py"
|
||||||
|
|
||||||
settings="$final_path/settings.py"
|
ynh_add_config --template="settings.py" --destination="$final_path/settings.py"
|
||||||
cp "../conf/settings.py" "$settings"
|
ynh_add_config --template="setup_user.py" --destination="$final_path/setup_user.py"
|
||||||
|
ynh_add_config --template="urls.py" --destination="$final_path/urls.py"
|
||||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$settings"
|
ynh_add_config --template="wsgi.py" --destination="$final_path/wsgi.py"
|
||||||
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__ADMINMAIL__" --replace_string="$admin_mail" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__FINAL_HOME_PATH__" --replace_string="$final_path" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__FINAL_WWW_PATH__" --replace_string="$public_path" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__LOG_FILE__" --replace_string="$log_file" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$settings"
|
|
||||||
|
|
||||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="$settings"
|
|
||||||
|
|
||||||
# Calculate and store the config file checksum into the app settings
|
|
||||||
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"
|
touch "$final_path/local_settings.py"
|
||||||
|
|
||||||
|
@ -162,25 +155,21 @@ touch "$final_path/local_settings.py"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="migrate/collectstatic/createadmin..." --weight=10
|
ynh_script_progression --message="migrate/collectstatic/createadmin..." --weight=10
|
||||||
|
|
||||||
(
|
cd "$final_path" || exit
|
||||||
set +o nounset
|
|
||||||
source "${final_path}/venv/bin/activate"
|
|
||||||
set -o nounset
|
|
||||||
cd "${final_path}"
|
|
||||||
|
|
||||||
# Just for debugging:
|
# Just for debugging:
|
||||||
./manage.py diffsettings
|
./manage.py diffsettings
|
||||||
|
|
||||||
./manage.py migrate --no-input
|
./manage.py migrate --no-input
|
||||||
./manage.py collectstatic --no-input
|
./manage.py collectstatic --no-input
|
||||||
|
|
||||||
# Create/update Django superuser (set unusable password, because auth done via SSOwat):
|
# Create/update Django superuser (set unusable password, because auth done via SSOwat):
|
||||||
./manage.py create_superuser --username="$admin" --email="$admin_mail"
|
./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.
|
||||||
|
./manage.py check --deploy || true
|
||||||
|
|
||||||
# Check the configuration
|
|
||||||
# This may fail in some cases with errors, etc., but the app works and the user can fix issues later.
|
|
||||||
./manage.py check --deploy || true
|
|
||||||
)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
|
@ -205,16 +194,21 @@ yunohost service add $app --description="Web based management to catalog things"
|
||||||
|
|
||||||
# Set permissions to app files
|
# Set permissions to app files
|
||||||
chown -R "$app:" "$log_path"
|
chown -R "$app:" "$log_path"
|
||||||
chown -R "$app:" "$public_path"
|
chown -R "$app:www-data" "$public_path"
|
||||||
chown -R "$app:" "$final_path"
|
chown -R "$app:" "$final_path"
|
||||||
|
|
||||||
|
chmod o-rwx "$log_path"
|
||||||
|
chmod o-rwx "$public_path"
|
||||||
|
chmod o-rwx "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring a systemd service..."
|
ynh_script_progression --message="Configuring a systemd service..."
|
||||||
|
|
||||||
# https://github.com/YunoHost/yunohost/blob/dev/data/helpers.d/systemd
|
# https://yunohost.org/en/contribute/packaging_apps/helpers
|
||||||
ynh_add_systemd_config --service="$app" --template="django_example_ynh.service"
|
# https://github.com/YunoHost/yunohost/blob/dev/helpers/systemd
|
||||||
|
ynh_add_systemd_config --service="$app" --template="systemd.service"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
|
@ -232,7 +226,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# Start django_example_ynh via systemd
|
# Start django_example_ynh via systemd
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting PyInventory's services..." --weight=5
|
ynh_script_progression --message="Starting django_example_ynh's services..." --weight=5
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app" --action="start"
|
ynh_systemd_action --service_name="$app" --action="start"
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading settings..."
|
ynh_script_progression --message="Loading settings..."
|
||||||
|
|
||||||
public_path=$(ynh_app_setting_get --app="$app" --key=public_path)
|
|
||||||
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
|
public_path=$(ynh_app_setting_get --app="$app" --key=public_path)
|
||||||
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
|
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
|
db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
|
||||||
|
@ -34,8 +34,6 @@ path_url=$(ynh_app_setting_get --app="$app" --key=path)
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Validating restoration parameters..."
|
ynh_script_progression --message="Validating restoration parameters..."
|
||||||
|
|
||||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
|
||||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
|
||||||
test ! -d $final_path \
|
test ! -d $final_path \
|
||||||
|| ynh_die --message="There is already a directory: $final_path "
|
|| ynh_die --message="There is already a directory: $final_path "
|
||||||
|
|
||||||
|
@ -52,10 +50,8 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the app main directory..."
|
ynh_script_progression --message="Restoring the app main directory..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$public_path"
|
|
||||||
ynh_restore_file --origin_path="$final_path"
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
ynh_restore_file --origin_path="$public_path"
|
||||||
touch "$final_path/local_settings.py"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECREATE THE DEDICATED USER
|
# RECREATE THE DEDICATED USER
|
||||||
|
@ -70,7 +66,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Restore permissions on app files
|
# Restore permissions on app files
|
||||||
chown -R "$app:" "$public_path"
|
chown -R "$app:www-data" "$public_path"
|
||||||
chown -R "$app:" "$final_path"
|
chown -R "$app:" "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -78,10 +74,37 @@ chown -R "$app:" "$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=40
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=20
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
|
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# PYTHON VIRTUALENV
|
||||||
|
# Maybe the backup contains a other Python version
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Recreate Python virtualenv..." --weight=5
|
||||||
|
|
||||||
|
# Always recreate everything fresh with current python version
|
||||||
|
ynh_secure_remove "${final_path}/venv"
|
||||||
|
|
||||||
|
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
|
||||||
|
python3 -m venv --without-pip "${final_path}/venv"
|
||||||
|
chown -R "$app:" "$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# PIP INSTALLATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Install project via pip..." --weight=45
|
||||||
|
#run source in a 'sub shell'
|
||||||
|
(
|
||||||
|
set +o nounset
|
||||||
|
source "${final_path}/venv/bin/activate"
|
||||||
|
set -o nounset
|
||||||
|
ynh_exec_as $app $final_path/venv/bin/python3 -m ensurepip
|
||||||
|
ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade wheel pip setuptools
|
||||||
|
ynh_exec_as $app $final_path/venv/bin/pip3 install --no-deps -r "$final_path/requirements.txt"
|
||||||
|
)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE PostgreSQL DATABASE
|
# RESTORE THE PostgreSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -115,6 +138,21 @@ touch "${log_file}"
|
||||||
chown -R "$app:" "$log_path"
|
chown -R "$app:" "$log_path"
|
||||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# SECURE FILES AND DIRECTORIES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Set permissions to app files
|
||||||
|
chown -R "$app:" "$log_path"
|
||||||
|
chown -R "$app:www-data" "$public_path"
|
||||||
|
chown -R "$app:" "$final_path"
|
||||||
|
|
||||||
|
chmod o-rwx "$log_path"
|
||||||
|
chmod o-rwx "$public_path"
|
||||||
|
chmod o-rwx "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
125
scripts/upgrade
125
scripts/upgrade
|
@ -13,7 +13,6 @@ source /usr/share/yunohost/helpers
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
admin=$(ynh_app_setting_get --app="$app" --key=admin)
|
admin=$(ynh_app_setting_get --app="$app" --key=admin)
|
||||||
is_public=$(ynh_app_setting_get --app="$app" --key=is_public)
|
|
||||||
public_path=$(ynh_app_setting_get --app="$app" --key=public_path)
|
public_path=$(ynh_app_setting_get --app="$app" --key=public_path)
|
||||||
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||||
log_path=$(ynh_app_setting_get --app="$app" --key=log_path)
|
log_path=$(ynh_app_setting_get --app="$app" --key=log_path)
|
||||||
|
@ -22,10 +21,20 @@ domain=$(ynh_app_setting_get --app="$app" --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app="$app" --key=path)
|
path_url=$(ynh_app_setting_get --app="$app" --key=path)
|
||||||
|
|
||||||
port=$(ynh_app_setting_get --app="$app" --key=port)
|
port=$(ynh_app_setting_get --app="$app" --key=port)
|
||||||
|
|
||||||
db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
|
db_pwd=$(ynh_app_setting_get --app="$app" --key=psqlpwd)
|
||||||
|
db_name=$(ynh_sanitize_dbid --db_name="$app")
|
||||||
|
db_user=$db_name
|
||||||
|
|
||||||
admin_mail=$(ynh_user_get_info "$admin" mail)
|
admin_mail=$(ynh_user_get_info "$admin" mail)
|
||||||
redis_db=$(ynh_app_setting_get --app="$app" --key=redis_db)
|
redis_db=$(ynh_app_setting_get --app="$app" --key=redis_db)
|
||||||
|
|
||||||
|
debug_enabled=$(ynh_app_setting_get --app="$app" --key=debug_enabled)
|
||||||
|
if [ -z "$debug_enabled" ]; then
|
||||||
|
debug_enabled="0"
|
||||||
|
ynh_app_setting_set --app="$app" --key=debug_enabled --value="$debug_enabled"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -49,13 +58,21 @@ ynh_script_progression --message="Stopping systemd services..." --weight=5
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app" --action="stop"
|
ynh_systemd_action --service_name="$app" --action="stop"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# Manage old settings
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Always deactivate settings.DEBUG:
|
||||||
|
ynh_app_setting_set --app=$app --key=debug_enabled --value="False"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading nginx web server configuration..."
|
ynh_script_progression --message="Upgrading nginx web server configuration..."
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
# https://github.com/YunoHost/yunohost/blob/dev/data/helpers.d/nginx
|
# https://yunohost.org/en/contribute/packaging_apps/helpers
|
||||||
|
# https://github.com/YunoHost/yunohost/blob/dev/helpers/nginx
|
||||||
ynh_add_nginx_config "public_path" "port"
|
ynh_add_nginx_config "public_path" "port"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -63,7 +80,7 @@ ynh_add_nginx_config "public_path" "port"
|
||||||
#=================================================
|
#=================================================
|
||||||
# Update dependencies
|
# Update dependencies
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..."
|
ynh_script_progression --message="Upgrading dependencies..." --weight=20
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
|
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
|
|
||||||
|
@ -80,24 +97,34 @@ ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring a systemd service..."
|
ynh_script_progression --message="Configuring a systemd service..."
|
||||||
|
|
||||||
ynh_add_systemd_config --service="$app" --template="django_example_ynh.service"
|
ynh_add_systemd_config --service="$app" --template="systemd.service"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE VENV
|
# PYTHON VIRTUALENV
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrade project via pip..." --weight=80
|
ynh_script_progression --message="Recreate Python virtualenv..." --weight=5
|
||||||
|
|
||||||
|
# Always recreate everything fresh with current python version
|
||||||
|
ynh_secure_remove "${final_path}/venv"
|
||||||
|
|
||||||
|
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
|
||||||
|
python3 -m venv --without-pip "${final_path}/venv"
|
||||||
|
|
||||||
python3 -m venv "${final_path}/venv"
|
|
||||||
cp ../conf/requirements.txt "$final_path/requirements.txt"
|
cp ../conf/requirements.txt "$final_path/requirements.txt"
|
||||||
chown -R "$app:" "$final_path"
|
chown -R "$app:" "$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# PIP INSTALLATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Install project via pip..." --weight=45
|
||||||
#run source in a 'sub shell'
|
#run source in a 'sub shell'
|
||||||
(
|
(
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "${final_path}/venv/bin/activate"
|
source "${final_path}/venv/bin/activate"
|
||||||
set -o nounset
|
set -o nounset
|
||||||
ynh_exec_as $app $final_path/venv/bin/pip install --upgrade pip
|
ynh_exec_as $app $final_path/venv/bin/python3 -m ensurepip
|
||||||
ynh_exec_as $app $final_path/venv/bin/pip install -r "$final_path/requirements.txt"
|
ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade wheel pip setuptools
|
||||||
|
ynh_exec_as $app $final_path/venv/bin/pip3 install --no-deps -r "$final_path/requirements.txt"
|
||||||
)
|
)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -105,74 +132,36 @@ chown -R "$app:" "$final_path"
|
||||||
# ================================================
|
# ================================================
|
||||||
ynh_script_progression --message="Create project configuration files..."
|
ynh_script_progression --message="Create project configuration files..."
|
||||||
|
|
||||||
gunicorn_conf="$final_path/gunicorn.conf.py"
|
ynh_add_config --template="gunicorn.conf.py" --destination="$final_path/gunicorn.conf.py"
|
||||||
ynh_backup_if_checksum_is_different --file="$gunicorn_conf"
|
|
||||||
cp "../conf/gunicorn.conf.py" "$gunicorn_conf"
|
|
||||||
ynh_replace_string --match_string="__FINAL_HOME_PATH__" --replace_string="$final_path" --target_file="$gunicorn_conf"
|
|
||||||
ynh_replace_string --match_string="__LOG_FILE__" --replace_string="$log_file" --target_file="$gunicorn_conf"
|
|
||||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$gunicorn_conf"
|
|
||||||
ynh_store_file_checksum --file="$gunicorn_conf"
|
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different --file="$final_path/manage.py"
|
ynh_add_config --template="manage.py" --destination="$final_path/manage.py"
|
||||||
cp ../conf/manage.py "$final_path/manage.py"
|
|
||||||
chmod +x "$final_path/manage.py"
|
chmod +x "$final_path/manage.py"
|
||||||
|
|
||||||
# save old settings file
|
ynh_add_config --template="settings.py" --destination="$final_path/settings.py"
|
||||||
settings="$final_path/settings.py"
|
ynh_add_config --template="setup_user.py" --destination="$final_path/setup_user.py"
|
||||||
ynh_backup_if_checksum_is_different --file="$settings"
|
ynh_add_config --template="urls.py" --destination="$final_path/urls.py"
|
||||||
|
ynh_add_config --template="wsgi.py" --destination="$final_path/wsgi.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"
|
|
||||||
ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__ADMINMAIL__" --replace_string="$admin_mail" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__FINAL_HOME_PATH__" --replace_string="$final_path" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__FINAL_WWW_PATH__" --replace_string="$public_path" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__LOG_FILE__" --replace_string="$log_file" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__REDIS_DB__" --replace_string="$redis_db" --target_file="$settings"
|
|
||||||
|
|
||||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$settings"
|
|
||||||
ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="$settings"
|
|
||||||
|
|
||||||
# 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"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MIGRATE PYINVENTORY
|
# MIGRATE PYINVENTORY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="migrate/collectstatic/createadmin..." --weight=10
|
ynh_script_progression --message="migrate/collectstatic/createadmin..." --weight=10
|
||||||
|
|
||||||
(
|
cd "$final_path" || exit
|
||||||
set +o nounset
|
|
||||||
source "${final_path}/venv/bin/activate"
|
|
||||||
set -o nounset
|
|
||||||
cd "${final_path}"
|
|
||||||
|
|
||||||
# Just for debugging:
|
# Just for debugging:
|
||||||
./manage.py diffsettings
|
./manage.py diffsettings
|
||||||
|
|
||||||
./manage.py migrate --no-input
|
./manage.py migrate --no-input
|
||||||
./manage.py collectstatic --no-input
|
./manage.py collectstatic --no-input
|
||||||
|
|
||||||
# Create/update Django superuser (set unusable password, because auth done via SSOwat):
|
# Create/update Django superuser (set unusable password, because auth done via SSOwat):
|
||||||
./manage.py create_superuser --username="$admin" --email="$admin_mail"
|
./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.
|
||||||
|
./manage.py check --deploy || true
|
||||||
|
|
||||||
# Check the configuration
|
|
||||||
# This may fail in some cases with errors, etc., but the app works and the user can fix issues later.
|
|
||||||
./manage.py check --deploy || true
|
|
||||||
)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
|
@ -197,13 +186,17 @@ yunohost service add $app --description="Web based management to catalog things"
|
||||||
|
|
||||||
# Set permissions to app files
|
# Set permissions to app files
|
||||||
chown -R "$app:" "$log_path"
|
chown -R "$app:" "$log_path"
|
||||||
chown -R "$app:" "$public_path"
|
chown -R "$app:www-data" "$public_path"
|
||||||
chown -R "$app:" "$final_path"
|
chown -R "$app:" "$final_path"
|
||||||
|
|
||||||
|
chmod o-rwx "$log_path"
|
||||||
|
chmod o-rwx "$public_path"
|
||||||
|
chmod o-rwx "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# Start django_example_ynh via systemd
|
# Start django_example_ynh via systemd
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting PyInventory's services..." --weight=5
|
ynh_script_progression --message="Starting django_example_ynh's services..." --weight=5
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app" --action="start"
|
ynh_systemd_action --service_name="$app" --action="start"
|
||||||
|
|
||||||
|
|
41
tests/conftest.py
Normal file
41
tests/conftest.py
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
"""
|
||||||
|
Special pytest init:
|
||||||
|
|
||||||
|
- Build a "local_test" YunoHost installation
|
||||||
|
- init Django with this local test installation
|
||||||
|
|
||||||
|
So the pytests will run against this local test installation
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import django
|
||||||
|
|
||||||
|
from django_yunohost_integration.local_test import create_local_test
|
||||||
|
|
||||||
|
|
||||||
|
BASE_PATH = Path(__file__).parent.parent
|
||||||
|
|
||||||
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_configure():
|
||||||
|
print('Compile YunoHost files...')
|
||||||
|
final_path = create_local_test(
|
||||||
|
django_settings_path=BASE_PATH / 'conf' / 'settings.py',
|
||||||
|
destination=BASE_PATH / 'local_test',
|
||||||
|
runserver=False,
|
||||||
|
extra_replacements={
|
||||||
|
'__DEBUG_ENABLED__': '0',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
print('Local test files created here:')
|
||||||
|
print(f'"{final_path}"')
|
||||||
|
|
||||||
|
os.chdir(final_path)
|
||||||
|
final_home_str = str(final_path)
|
||||||
|
if final_home_str not in sys.path:
|
||||||
|
sys.path.insert(0, final_home_str)
|
||||||
|
|
||||||
|
django.setup()
|
|
@ -4,8 +4,8 @@ from django.conf import settings
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.test import override_settings
|
from django.test import override_settings
|
||||||
from django.test.testcases import TestCase
|
from django.test.testcases import TestCase
|
||||||
from django.urls import NoReverseMatch
|
|
||||||
from django.urls.base import reverse
|
from django.urls.base import reverse
|
||||||
|
|
||||||
from django_yunohost_integration.test_utils import generate_basic_auth
|
from django_yunohost_integration.test_utils import generate_basic_auth
|
||||||
from django_yunohost_integration.views import request_media_debug_view
|
from django_yunohost_integration.views import request_media_debug_view
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase):
|
||||||
def test_settings(self):
|
def test_settings(self):
|
||||||
assert settings.PATH_URL == 'app_path'
|
assert settings.PATH_URL == 'app_path'
|
||||||
|
|
||||||
assert str(settings.FINAL_HOME_PATH).endswith('/local_test/opt_yunohost')
|
assert str(settings.FINALPATH).endswith('/local_test/opt_yunohost')
|
||||||
assert str(settings.FINAL_WWW_PATH).endswith('/local_test/var_www')
|
assert str(settings.PUBLIC_PATH).endswith('/local_test/var_www')
|
||||||
assert str(settings.LOG_FILE).endswith('/local_test/var_log_django_example_ynh.log')
|
assert str(settings.LOG_FILE).endswith('/local_test/var_log_django_example_ynh.log')
|
||||||
|
|
||||||
assert settings.ROOT_URLCONF == 'urls'
|
assert settings.ROOT_URLCONF == 'urls'
|
||||||
|
@ -30,19 +30,43 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase):
|
||||||
def test_urls(self):
|
def test_urls(self):
|
||||||
assert reverse('admin:index') == '/app_path/'
|
assert reverse('admin:index') == '/app_path/'
|
||||||
|
|
||||||
# The django_yunohost_integration debug view should not be avaiable:
|
def test_request_media_debug_view(self):
|
||||||
with self.assertRaises(NoReverseMatch):
|
assert reverse(request_media_debug_view) == '/app_path/debug/'
|
||||||
reverse(request_media_debug_view)
|
|
||||||
|
|
||||||
# Serve user uploads via django_tools.serve_media_app:
|
self.client.cookies['SSOwAuthUser'] = 'test'
|
||||||
assert settings.MEDIA_URL == '/app_path/media/'
|
kwargs = dict(
|
||||||
assert reverse('serve_media_app:serve-media', kwargs={'user_token': 'token', 'path': 'foo/bar/'}) == (
|
path='/app_path/debug/',
|
||||||
'/app_path/media/token/foo/bar/'
|
HTTP_REMOTE_USER='test',
|
||||||
|
HTTP_AUTH_USER='test',
|
||||||
|
HTTP_AUTHORIZATION='basic dGVzdDp0ZXN0MTIz',
|
||||||
|
secure=True,
|
||||||
|
)
|
||||||
|
assert settings.DEBUG is False
|
||||||
|
with self.assertRaisesMessage(AssertionError, 'Only in DEBUG mode available!'):
|
||||||
|
self.client.get(**kwargs)
|
||||||
|
|
||||||
|
with override_settings(DEBUG=True):
|
||||||
|
response = self.client.get(**kwargs)
|
||||||
|
self.assert_html_parts(
|
||||||
|
response,
|
||||||
|
parts=('request.META',),
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_auth(self):
|
def test_auth(self):
|
||||||
response = self.client.get('/app_path/')
|
# SecurityMiddleware should redirects all non-HTTPS requests to HTTPS:
|
||||||
self.assertRedirects(response, expected_url='/app_path/login/?next=/app_path/')
|
assert settings.SECURE_SSL_REDIRECT is True
|
||||||
|
response = self.client.get('/app_path/', secure=False)
|
||||||
|
self.assertRedirects(
|
||||||
|
response,
|
||||||
|
status_code=301, # permanent redirect
|
||||||
|
expected_url='https://testserver/app_path/',
|
||||||
|
fetch_redirect_response=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
response = self.client.get('/app_path/', secure=True)
|
||||||
|
self.assertRedirects(
|
||||||
|
response, expected_url='/app_path/login/?next=/app_path/', fetch_redirect_response=False
|
||||||
|
)
|
||||||
|
|
||||||
def test_create_unknown_user(self):
|
def test_create_unknown_user(self):
|
||||||
assert User.objects.count() == 0
|
assert User.objects.count() == 0
|
||||||
|
@ -54,6 +78,7 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase):
|
||||||
HTTP_REMOTE_USER='test',
|
HTTP_REMOTE_USER='test',
|
||||||
HTTP_AUTH_USER='test',
|
HTTP_AUTH_USER='test',
|
||||||
HTTP_AUTHORIZATION='basic dGVzdDp0ZXN0MTIz',
|
HTTP_AUTHORIZATION='basic dGVzdDp0ZXN0MTIz',
|
||||||
|
secure=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert User.objects.count() == 1
|
assert User.objects.count() == 1
|
||||||
|
@ -66,7 +91,7 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase):
|
||||||
self.assert_html_parts(
|
self.assert_html_parts(
|
||||||
response,
|
response,
|
||||||
parts=(
|
parts=(
|
||||||
f'<title>Site administration</title>',
|
'<h1 id="site-name"><a href="/app_path/">Django administration</a></h1>',
|
||||||
'<strong>test</strong>',
|
'<strong>test</strong>',
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -82,6 +107,7 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase):
|
||||||
HTTP_REMOTE_USER='test',
|
HTTP_REMOTE_USER='test',
|
||||||
HTTP_AUTH_USER='foobar', # <<< wrong user name
|
HTTP_AUTH_USER='foobar', # <<< wrong user name
|
||||||
HTTP_AUTHORIZATION='basic dGVzdDp0ZXN0MTIz',
|
HTTP_AUTHORIZATION='basic dGVzdDp0ZXN0MTIz',
|
||||||
|
secure=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert User.objects.count() == 1
|
assert User.objects.count() == 1
|
||||||
|
@ -106,6 +132,7 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase):
|
||||||
HTTP_REMOTE_USER='test',
|
HTTP_REMOTE_USER='test',
|
||||||
HTTP_AUTH_USER='test',
|
HTTP_AUTH_USER='test',
|
||||||
HTTP_AUTHORIZATION='basic dGVzdDp0ZXN0MTIz',
|
HTTP_AUTHORIZATION='basic dGVzdDp0ZXN0MTIz',
|
||||||
|
secure=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert User.objects.count() == 1
|
assert User.objects.count() == 1
|
||||||
|
@ -128,7 +155,11 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase):
|
||||||
path='/app_path/',
|
path='/app_path/',
|
||||||
HTTP_REMOTE_USER='test',
|
HTTP_REMOTE_USER='test',
|
||||||
HTTP_AUTH_USER='test',
|
HTTP_AUTH_USER='test',
|
||||||
HTTP_AUTHORIZATION=generate_basic_auth(username='foobar', password='test123'), # <<< wrong user name
|
HTTP_AUTHORIZATION=generate_basic_auth(
|
||||||
|
username='foobar', # <<< wrong user name
|
||||||
|
password='test123',
|
||||||
|
),
|
||||||
|
secure=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert User.objects.count() == 1
|
assert User.objects.count() == 1
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
import shutil
|
|
||||||
import subprocess
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
|
|
||||||
BASE_PATH = Path(__file__).parent.parent
|
|
||||||
|
|
||||||
|
|
||||||
def test_lint():
|
|
||||||
assert Path(BASE_PATH, 'Makefile').is_file()
|
|
||||||
make_bin = shutil.which('make')
|
|
||||||
assert make_bin is not None
|
|
||||||
subprocess.check_call([make_bin, 'lint'], cwd=BASE_PATH)
|
|
|
@ -3,7 +3,7 @@ import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import django_yunohost_integration
|
import tomli
|
||||||
|
|
||||||
|
|
||||||
PACKAGE_ROOT = Path(__file__).parent.parent
|
PACKAGE_ROOT = Path(__file__).parent.parent
|
||||||
|
@ -18,11 +18,16 @@ def assert_file_contains_string(file_path, string):
|
||||||
|
|
||||||
|
|
||||||
def test_version():
|
def test_version():
|
||||||
version = django_yunohost_integration.__version__
|
pyproject_toml_path = Path(PACKAGE_ROOT, 'pyproject.toml')
|
||||||
|
pyproject_toml = tomli.loads(pyproject_toml_path.read_text(encoding='UTF-8'))
|
||||||
|
version = pyproject_toml['tool']['poetry']['version']
|
||||||
|
assert '~ynh' not in version
|
||||||
|
assert version[0].isdigit()
|
||||||
|
|
||||||
assert_file_contains_string(file_path=Path(PACKAGE_ROOT, 'pyproject.toml'), string=f'version = "{version}~ynh')
|
assert_file_contains_string(
|
||||||
assert_file_contains_string(file_path=Path(PACKAGE_ROOT, 'pyproject.toml'), string=f'django_yunohost_integration = "=={version}"')
|
file_path=Path(PACKAGE_ROOT, 'manifest.json'),
|
||||||
assert_file_contains_string(file_path=Path(PACKAGE_ROOT, 'manifest.json'), string=f'"version": "{version}~ynh')
|
string=f'"version": "{version}~ynh',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_poetry_check():
|
def test_poetry_check():
|
||||||
|
@ -30,7 +35,7 @@ def test_poetry_check():
|
||||||
|
|
||||||
output = subprocess.check_output(
|
output = subprocess.check_output(
|
||||||
[poerty_bin, 'check'],
|
[poerty_bin, 'check'],
|
||||||
universal_newlines=True,
|
text=True,
|
||||||
env=os.environ,
|
env=os.environ,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
cwd=str(PACKAGE_ROOT),
|
cwd=str(PACKAGE_ROOT),
|
||||||
|
|
Loading…
Add table
Reference in a new issue