From 52deb20e85d93e43013a2c0d8584b6b3a54faf15 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 22 Apr 2021 12:15:25 +1000 Subject: [PATCH 1/4] docker-compose improvements - Prepend "inventree" to the name of each container - Explicitly expose more env variables required for InvenTree db lookup - Adjust server name in nginx-conf file --- docker/Dockerfile | 10 ---------- docker/docker-compose.yml | 41 +++++++++++++++++++++++++-------------- docker/nginx.conf | 4 ++-- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 9682665e04..ab4dbba6b5 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -29,16 +29,6 @@ ENV INVENTREE_SECRET_KEY_FILE="${INVENTREE_DATA_DIR}/secret_key.txt" # Default web server port is 8000 ENV INVENTREE_WEB_PORT="8000" -# Pass DB configuration through as environment variables -# Default configuration = postgresql -ENV INVENTREE_DB_ENGINE="postgresql" -ENV INVENTREE_DB_NAME="inventree" -ENV INVENTREE_DB_HOST="db" -ENV INVENTREE_DB_PORT="5432" - -# INVENTREE_DB_USER must be specified at run-time -# INVENTREE_DB_PASSWORD must be specified at run-time - LABEL org.label-schema.schema-version="1.0" \ org.label-schema.build-date=${DATE} \ org.label-schema.vendor="inventree" \ diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index e48b22d4b7..c5c98f7d36 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -19,8 +19,8 @@ services: # Use PostgreSQL as the database backend # Note: this can be changed to a different backend, # just make sure that you change the INVENTREE_DB_xxx vars below - db: - container_name: db + inventree-db: + container_name: inventree-db image: postgres ports: - 5432/tcp @@ -35,49 +35,60 @@ services: # InvenTree web server services # Uses gunicorn as the web server - inventree: - container_name: inventree + inventree-server: + container_name: inventree-server image: inventree/inventree:latest expose: - 8000 depends_on: - - db + - inventree-db volumes: - data:/home/inventree/data - static:/home/inventree/static environment: # Default environment variables are configured to match the 'db' container - # Database permissions + # Note: If you change the database image, these will need to be adjusted + # Note: INVENTREE_DB_HOST should match the container name of the database - INVENTREE_DB_USER=pguser - INVENTREE_DB_PASSWORD=pgpassword + - INVENTREE_DB_ENGINE=postgresql + - INVENTREE_DB_NAME=inventree + - INVENTREE_DB_HOST=inventree-db + - INVENTREE_DB_PORT=5432 restart: unless-stopped # Background worker process handles long-running or periodic tasks - worker: - container_name: worker + inventree-worker: + container_name: inventree-worker image: inventree/inventree:latest entrypoint: ./start_worker.sh depends_on: - - db - - inventree + - inventree-db + - inventree-server volumes: - data:/home/inventree/data - static:/home/inventree/static environment: - # Default environment variables are configured to match the 'inventree' container + # Default environment variables are configured to match the 'db' container + # Note: If you change the database image, these will need to be adjusted + # Note: INVENTREE_DB_HOST should match the container name of the database - INVENTREE_DB_USER=pguser - INVENTREE_DB_PASSWORD=pgpassword + - INVENTREE_DB_ENGINE=postgresql + - INVENTREE_DB_NAME=inventree + - INVENTREE_DB_HOST=inventree-db + - INVENTREE_DB_PORT=5432 restart: unless-stopped # nginx acts as a reverse proxy # static files are served by nginx # web requests are redirected to gunicorn # NOTE: You will need to provide a working nginx.conf file! - proxy: - container_name: proxy + inventree-proxy: + container_name: inventree-proxy image: nginx depends_on: - - inventree + - inventree-server ports: # Change "1337" to the port that you want InvenTree web server to be available on - 1337:80 @@ -99,6 +110,6 @@ volumes: o: bind # This directory specified where InvenTree data are stored "outside" the docker containers # Change this path to a local system path where you want InvenTree data stored - device: /path/to/data + device: c:\my-inventree-data # Static files, shared between containers static: \ No newline at end of file diff --git a/docker/nginx.conf b/docker/nginx.conf index 7f275b4fa8..a9eff10fc5 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -4,9 +4,9 @@ server { listen 80; location / { - # Change 'inventree' to the name of the inventree server container, + # Change 'inventree-server' to the name of the inventree server container, # and '8000' to the INVENTREE_WEB_PORT (if not default) - proxy_pass http://inventree:8000; + proxy_pass http://inventree-server:8000; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; From 0c572486ba8a1c759bf27ce50bddec972b156f46 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 22 Apr 2021 12:49:11 +1000 Subject: [PATCH 2/4] Revert volume path --- docker/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index c5c98f7d36..9e77dd1181 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -110,6 +110,6 @@ volumes: o: bind # This directory specified where InvenTree data are stored "outside" the docker containers # Change this path to a local system path where you want InvenTree data stored - device: c:\my-inventree-data + device: /path/to/data # Static files, shared between containers static: \ No newline at end of file From 4a522bb05a01f19dd20d258d92a75a4ad7d2fba2 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 22 Apr 2021 14:53:42 +1000 Subject: [PATCH 3/4] Allow 'admin' account access to the report models --- InvenTree/users/models.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/InvenTree/users/models.py b/InvenTree/users/models.py index 73388a88bc..19937af190 100644 --- a/InvenTree/users/models.py +++ b/InvenTree/users/models.py @@ -59,6 +59,12 @@ class RuleSet(models.Model): 'authtoken_token', 'authtoken_tokenproxy', 'users_ruleset', + 'report_reportasset', + 'report_reportsnippet', + 'report_billofmaterialsreport', + 'report_purchaseorderreport', + 'report_salesorderreport', + ], 'part_category': [ 'part_partcategory', @@ -128,11 +134,6 @@ class RuleSet(models.Model): 'common_colortheme', 'common_inventreesetting', 'company_contact', - 'report_reportasset', - 'report_reportsnippet', - 'report_billofmaterialsreport', - 'report_purchaseorderreport', - 'report_salesorderreport', 'users_owner', # Third-party tables From 294dd0525f8ca3c9ac85639134874fd72f0e173b Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 22 Apr 2021 12:53:49 +0200 Subject: [PATCH 4/4] use spaces instead of tabs --- .../part/templates/part/category_parametric.html | 16 ++++++++-------- .../templates/InvenTree/settings/category.html | 6 +++--- .../templates/InvenTree/settings/stock.html | 2 +- .../templates/InvenTree/settings/theme.html | 12 ++++++------ 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/InvenTree/part/templates/part/category_parametric.html b/InvenTree/part/templates/part/category_parametric.html index 250530309e..881a292986 100644 --- a/InvenTree/part/templates/part/category_parametric.html +++ b/InvenTree/part/templates/part/category_parametric.html @@ -19,18 +19,18 @@ {% block js_ready %} {{ block.super }} - - /* Hide Button Toolbar */ - window.onload = function hideButtonToolbar() { - var toolbar = document.getElementById("button-toolbar"); - toolbar.style.display = "none"; - }; + + /* Hide Button Toolbar */ + window.onload = function hideButtonToolbar() { + var toolbar = document.getElementById("button-toolbar"); + toolbar.style.display = "none"; + }; loadParametricPartTable( "#parametric-part-table", { - headers: {{ headers|safe }}, - data: {{ parameters|safe }}, + headers: {{ headers|safe }}, + data: {{ parameters|safe }}, } ); diff --git a/InvenTree/templates/InvenTree/settings/category.html b/InvenTree/templates/InvenTree/settings/category.html index 07dd0df342..0e70d2c90e 100644 --- a/InvenTree/templates/InvenTree/settings/category.html +++ b/InvenTree/templates/InvenTree/settings/category.html @@ -44,7 +44,7 @@ }); {% if category %} - $("#param-table").inventreeTable({ + $("#param-table").inventreeTable({ url: "{% url 'api-part-category-parameters' pk=category.pk %}", queryParams: { ordering: 'name', @@ -66,7 +66,7 @@ field: 'default_value', title: '{% trans "Default Value" %}', sortable: 'true', - formatter: function(value, row, index, field) { + formatter: function(value, row, index, field) { var bEdit = ""; var bDel = ""; @@ -79,7 +79,7 @@ ] }); - $("#new-param").click(function() { + $("#new-param").click(function() { launchModalForm("{% url 'category-param-template-create' category.pk %}", { success: function() { $("#param-table").bootstrapTable('refresh'); diff --git a/InvenTree/templates/InvenTree/settings/stock.html b/InvenTree/templates/InvenTree/settings/stock.html index 7909e11a60..7cf7a94e0b 100644 --- a/InvenTree/templates/InvenTree/settings/stock.html +++ b/InvenTree/templates/InvenTree/settings/stock.html @@ -21,7 +21,7 @@ {% include "InvenTree/settings/setting.html" with key="STOCK_STALE_DAYS" icon="fa-calendar" %} {% include "InvenTree/settings/setting.html" with key="STOCK_ALLOW_EXPIRED_SALE" icon="fa-truck" %} {% include "InvenTree/settings/setting.html" with key="STOCK_ALLOW_EXPIRED_BUILD" icon="fa-tools" %} - {% include "InvenTree/settings/setting.html" with key="STOCK_OWNERSHIP_CONTROL" icon="fa-users" %} + {% include "InvenTree/settings/setting.html" with key="STOCK_OWNERSHIP_CONTROL" icon="fa-users" %} {% endblock %} diff --git a/InvenTree/templates/InvenTree/settings/theme.html b/InvenTree/templates/InvenTree/settings/theme.html index 413bb67dd3..d7b006d13c 100644 --- a/InvenTree/templates/InvenTree/settings/theme.html +++ b/InvenTree/templates/InvenTree/settings/theme.html @@ -25,12 +25,12 @@ {% if invalid_color_theme %} - + {% endif %} {% endblock %}