From 0a017fde23b851b76a72b4db66da8df96aff4770 Mon Sep 17 00:00:00 2001 From: Shraddha Agrawal Date: Jun 04 2019 12:20:38 +0000 Subject: Auto reload code changes This commit adds: 1. The functionailty to auto reload code changes made to the code base without having to build containers again to see them in effect. 2. The documentation update for the above. 3. Resolve HTML escaping on the search index page --- diff --git a/.gitignore b/.gitignore index e96d67e..312a8b7 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,10 @@ client_secrets.json fas-admin-details.json # YAML Configuration file for django -config.yml \ No newline at end of file +config.yml + +# Django-haystack files +whoosh_index/ + +# VS Code files +.vscode/ diff --git a/docker-compose.yml b/docker-compose.yml index 706f073..83a0bfb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,12 @@ version: "3" services: web: build: . + restart: always command: bash -c "python manage.py migrate --noinput && python manage.py rebuild_index --noinput && python manage.py runserver 0.0.0.0:8000" + volumes: + - ./templates:/app/templates:z + - ./assets:/app/assets:z + - ./happinesspackets:/app/happinesspackets:z ports: - "8000:8000" links: diff --git a/docs/setup/development.rst b/docs/setup/development.rst index 02e6f3e..ae04eda 100644 --- a/docs/setup/development.rst +++ b/docs/setup/development.rst @@ -32,16 +32,17 @@ The project comes with a Dockerfile that allows easy deployment of a web server. ./generate_client_secrets.sh + Although the Dockerfile runs the script to check if a client_secrets.json file is present, please generate it before starting the Docker container, so that client secrets are not being constantly generated every time the image is rebuilt. + #. Create a fas-admin-details.json file and add a json object with your FAS-Username and FAS-Password. See fas-admin-details.json.example. #. Create a config.yml file and populate it with the user's details and usernames for `ADMINS `_ and superuser privileges respectively. -Although the Dockerfile runs the script to check if a client_secrets.json file is present, please generate it before starting the Docker container, so that client secrets are not being constantly generated every time the image is rebuilt. - In order to run the web server, alongside the Redis queue and celery worker instance, simply run ``docker-compose up``. After this, you can access the local development server at ``http://localhost:8000/`` in your web browser. -If you have made any changes to the code, the Docker image must be rebuilt; this can be done my running ``docker-compose up --build``. +Auto reload of code changes is configured, so you shouldn't have to rebuild containers every time you make changes to the code base. +If you have made any changes to the environment of the containers (eg - adding a new dependency), the Docker image must be rebuilt; this can be done my running ``docker-compose up --build``. Since the code is being run in a container, we must enter the shell of the container in order to run tests. Access the shell of the Docker container by running ``docker-compose exec web sh``. diff --git a/templates/search/search.html b/templates/search/search.html index 1cf8291..8bdf4e0 100644 --- a/templates/search/search.html +++ b/templates/search/search.html @@ -26,7 +26,7 @@
- {{ result.object.message|linebreaksbr }} + {{ result.object.message|safe }}
{% empty %}