From de578251ac4a0a0ade2674c09e5fda3e388c584d Mon Sep 17 00:00:00 2001 From: Lukas <76838159+wolflu05@users.noreply.github.com> Date: Tue, 20 Dec 2022 14:37:41 +0100 Subject: [PATCH] Make plugin installable in production (#3) * Added __init__.py to migrations folder * fix migration and added MANIFEST.in to also include static and templates * Added include_package_data=True option * Move static files into sub-directory * Updated installation instructions and added MIN_VERSION --- MANIFEST.in | 4 ++++ README.md | 24 ++++++++----------- inventree_bulk/BulkActionPlugin.py | 1 + inventree_bulk/BulkGenerator/__init__.py | 0 inventree_bulk/migrations/0001_initial.py | 3 ++- .../static/{ => inventree-bulk}/htm.LICENSE | 0 .../static/{ => inventree-bulk}/htm.js | 0 .../{ => inventree-bulk}/preact.LICENSE | 0 .../static/{ => inventree-bulk}/preact.js | 0 .../panels/category-detail/create-bulk.html | 4 ++-- .../panels/stock-index/manage-bulk.html | 4 ++-- .../stock-location-detail/create-bulk.html | 4 ++-- setup.py | 2 ++ 13 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 MANIFEST.in create mode 100644 inventree_bulk/BulkGenerator/__init__.py rename inventree_bulk/static/{ => inventree-bulk}/htm.LICENSE (100%) rename inventree_bulk/static/{ => inventree-bulk}/htm.js (100%) rename inventree_bulk/static/{ => inventree-bulk}/preact.LICENSE (100%) rename inventree_bulk/static/{ => inventree-bulk}/preact.js (100%) diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..2fbbab2 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,4 @@ +include LICENSE +include README.md +recursive-include inventree_bulk/static * +recursive-include inventree_bulk/templates * \ No newline at end of file diff --git a/README.md b/README.md index 4fc32c8..9d39439 100644 --- a/README.md +++ b/README.md @@ -9,19 +9,15 @@ A bulk creation plugin for [InvenTree](https://inventree.org), which helps you g ## Installation -1. Install this plugin as follows: - - ```bash - pip install git+https://github.com/wolflu05/inventree-bulk-plugin - ``` - - Or, add to your `plugins.txt` file: - - ```txt - git+https://github.com/wolflu05/inventree-bulk-plugin - ``` - -2. Goto your plugin settings and ensure that you allow the use of the url integration and app integration +Install this plugin as follows: + +1. Make sure you allow the use of the url integration and app integration (see [Why does this plugin needs the app mixin?](#why-does-this-plugin-needs-the-app-mixin)) + +2. Goto Settings > Plugins > Install Plugin, set `inventree-bulk-plugin` as package name and `git+https://github.com/wolflu05/inventree-bulk-plugin` as source URL. Enable the confirm switch and click submit. + +3. Restart your server and activate the plugin. + +4. Stop your server and run `invoke update` (for docker installs it is `docker-compose inventree-server invoke update`). This ensures that all migrations run and the static files get collected. You can now start your server again and start using the plugin. ## Usage @@ -73,7 +69,7 @@ Dimensions are a way to add various counting strategies to your naming. You can A `dimension` can be either specify a range or a generic name. You can use the count field to limit a generic dimension to a specific amount of generating items. -Ranges: `A-G`,`f-x`, `1-3`, `A-XZ` +Ranges: `A-G`,`f-x`, `1-3`, `A-XZ`
Generics: `NUMERIC` (0-9), `ALPHA_LOWER` (a-...), `ALPHA_UPPER` (A-...). ##### Generate diff --git a/inventree_bulk/BulkActionPlugin.py b/inventree_bulk/BulkActionPlugin.py index 371c33e..8ac21ca 100644 --- a/inventree_bulk/BulkActionPlugin.py +++ b/inventree_bulk/BulkActionPlugin.py @@ -27,6 +27,7 @@ class BulkActionPlugin(AppMixin, PanelMixin, UrlsMixin, InvenTreePlugin): AUTHOR = "wolflu05" DESCRIPTION = "Bulk action plugin" VERSION = BULK_PLUGIN_VERSION + MIN_VERSION = "0.9.1" # due to "invoke update" doesn't run collectstatic (see #inventree/InvenTree#4077) TITLE = "Bulk Action" SLUG = "bulkaction" diff --git a/inventree_bulk/BulkGenerator/__init__.py b/inventree_bulk/BulkGenerator/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/inventree_bulk/migrations/0001_initial.py b/inventree_bulk/migrations/0001_initial.py index 9bb1e75..75db0f5 100644 --- a/inventree_bulk/migrations/0001_initial.py +++ b/inventree_bulk/migrations/0001_initial.py @@ -1,6 +1,7 @@ # Generated by Django 3.2.16 on 2022-12-16 13:27 from django.db import migrations, models +from ..models import validate_template class Migration(migrations.Migration): @@ -17,7 +18,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=250)), ('template_type', models.CharField(max_length=100)), - ('template', models.TextField()), + ('template', models.TextField(validators=[validate_template])), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), ], diff --git a/inventree_bulk/static/htm.LICENSE b/inventree_bulk/static/inventree-bulk/htm.LICENSE similarity index 100% rename from inventree_bulk/static/htm.LICENSE rename to inventree_bulk/static/inventree-bulk/htm.LICENSE diff --git a/inventree_bulk/static/htm.js b/inventree_bulk/static/inventree-bulk/htm.js similarity index 100% rename from inventree_bulk/static/htm.js rename to inventree_bulk/static/inventree-bulk/htm.js diff --git a/inventree_bulk/static/preact.LICENSE b/inventree_bulk/static/inventree-bulk/preact.LICENSE similarity index 100% rename from inventree_bulk/static/preact.LICENSE rename to inventree_bulk/static/inventree-bulk/preact.LICENSE diff --git a/inventree_bulk/static/preact.js b/inventree_bulk/static/inventree-bulk/preact.js similarity index 100% rename from inventree_bulk/static/preact.js rename to inventree_bulk/static/inventree-bulk/preact.js diff --git a/inventree_bulk/templates/panels/category-detail/create-bulk.html b/inventree_bulk/templates/panels/category-detail/create-bulk.html index a6a21df..e32f9cb 100644 --- a/inventree_bulk/templates/panels/category-detail/create-bulk.html +++ b/inventree_bulk/templates/panels/category-detail/create-bulk.html @@ -1,6 +1,6 @@ {% load static %} - - + +
diff --git a/inventree_bulk/templates/panels/stock-index/manage-bulk.html b/inventree_bulk/templates/panels/stock-index/manage-bulk.html index 4782585..bcf7a2b 100644 --- a/inventree_bulk/templates/panels/stock-index/manage-bulk.html +++ b/inventree_bulk/templates/panels/stock-index/manage-bulk.html @@ -1,6 +1,6 @@ {% load static %} - - + +
diff --git a/inventree_bulk/templates/panels/stock-location-detail/create-bulk.html b/inventree_bulk/templates/panels/stock-location-detail/create-bulk.html index 71695b9..f001dc7 100644 --- a/inventree_bulk/templates/panels/stock-location-detail/create-bulk.html +++ b/inventree_bulk/templates/panels/stock-location-detail/create-bulk.html @@ -1,6 +1,6 @@ {% load static %} - - + +
diff --git a/setup.py b/setup.py index a188bfb..7a431f2 100644 --- a/setup.py +++ b/setup.py @@ -47,4 +47,6 @@ "BulkActionPlugin = inventree_bulk.BulkActionPlugin:BulkActionPlugin" ] }, + + include_package_data=True, )