diff --git a/.github/scripts/version_check.py b/.github/scripts/version_check.py index 68e2ff1e25..9e81d3885c 100644 --- a/.github/scripts/version_check.py +++ b/.github/scripts/version_check.py @@ -97,6 +97,9 @@ if __name__ == '__main__': ) text = version_file.read_text() results = re.findall(r"""INVENTREE_API_VERSION = (.*)""", text) + # If 2. args is true lower the version number by 1 + if len(sys.argv) > 2 and sys.argv[2] == 'true': + results[0] = str(int(results[0]) - 1) print(results[0]) exit(0) # GITHUB_REF_TYPE may be either 'branch' or 'tag' diff --git a/.github/workflows/qc_checks.yaml b/.github/workflows/qc_checks.yaml index 4df56dd40d..afbf24635e 100644 --- a/.github/workflows/qc_checks.yaml +++ b/.github/workflows/qc_checks.yaml @@ -164,15 +164,27 @@ jobs: name: schema.yml path: src/backend/InvenTree/schema.yml - name: Download public schema - if: needs.paths-filter.outputs.api == 'false' run: | pip install --require-hashes -r contrib/dev_reqs/requirements.txt >/dev/null 2>&1 - version="$(python3 .github/scripts/version_check.py only_version 2>&1)" + version="$(python3 .github/scripts/version_check.py only_version ${{ needs.paths-filter.outputs.api }} 2>&1)" echo "Version: $version" url="https://raw.githubusercontent.com/inventree/schema/main/export/${version}/api.yaml" echo "URL: $url" - curl -s -o api.yaml $url + code=$(curl -s -o api.yaml $url --write-out '%{http_code}' --silent) + if [ "$code" != "200" ]; then + exit 1 + fi echo "Downloaded api.yaml" + - name: Running OpenAPI Spec diff action + id: breaking_changes + uses: oasdiff/oasdiff-action/diff@main + with: + base: 'api.yaml' + revision: 'src/backend/InvenTree/schema.yml' + format: 'html' + - name: Echoing diff to step + run: echo "${{ steps.breaking_changes.outputs.diff }}" >> $GITHUB_STEP_SUMMARY + - name: Check for differences in API Schema if: needs.paths-filter.outputs.api == 'false' run: | diff --git a/src/backend/InvenTree/plugin/api.py b/src/backend/InvenTree/plugin/api.py index df1877bf56..2c5d3cc864 100644 --- a/src/backend/InvenTree/plugin/api.py +++ b/src/backend/InvenTree/plugin/api.py @@ -1,5 +1,7 @@ """API for the plugin app.""" +from typing import Optional + from django.core.exceptions import ValidationError from django.urls import include, path, re_path from django.utils.translation import gettext_lazy as _ @@ -266,7 +268,9 @@ class PluginSettingList(ListAPI): filterset_fields = ['plugin__active', 'plugin__key'] -def check_plugin(plugin_slug: str, plugin_pk: int) -> InvenTreePlugin: +def check_plugin( + plugin_slug: Optional[str], plugin_pk: Optional[int] +) -> InvenTreePlugin: """Check that a plugin for the provided slug exists and get the config. Args: @@ -286,16 +290,16 @@ def check_plugin(plugin_slug: str, plugin_pk: int) -> InvenTreePlugin: raise NotFound(detail='Plugin not specified') # Define filter - filter = {} + filters = {} if plugin_slug: - filter['key'] = plugin_slug + filters['key'] = plugin_slug elif plugin_pk: - filter['pk'] = plugin_pk + filters['pk'] = plugin_pk ref = plugin_slug or plugin_pk # Check that the 'plugin' specified is valid try: - plugin_cgf = PluginConfig.objects.filter(**filter).first() + plugin_cgf = PluginConfig.objects.filter(**filters).first() except PluginConfig.DoesNotExist: raise NotFound(detail=f"Plugin '{ref}' not installed") diff --git a/src/backend/InvenTree/report/templatetags/barcode.py b/src/backend/InvenTree/report/templatetags/barcode.py index e8f61c424f..85aeed953f 100644 --- a/src/backend/InvenTree/report/templatetags/barcode.py +++ b/src/backend/InvenTree/report/templatetags/barcode.py @@ -75,7 +75,7 @@ def barcode(data, barcode_class='code128', **kwargs): """Render a barcode.""" constructor = python_barcode.get_barcode_class(barcode_class) - format = kwargs.pop('format', 'PNG') + img_format = kwargs.pop('format', 'PNG') data = str(data).zfill(constructor.digits) @@ -86,4 +86,4 @@ def barcode(data, barcode_class='code128', **kwargs): image = barcode_image.render(writer_options=kwargs) # Render to byte-encoded image - return image_data(image, fmt=format) + return image_data(image, fmt=img_format) diff --git a/src/backend/InvenTree/templates/js/dynamic/nav.js b/src/backend/InvenTree/templates/js/dynamic/nav.js index 188e7be98b..4f5c73d328 100644 --- a/src/backend/InvenTree/templates/js/dynamic/nav.js +++ b/src/backend/InvenTree/templates/js/dynamic/nav.js @@ -173,7 +173,7 @@ function generateTreeStructure(data, options) { }; if (options.processNode) { - node = options.processNode(node); + data[data.indexOf(node)] = options.processNode(node); } } @@ -188,7 +188,7 @@ function generateTreeStructure(data, options) { if (node.state.expanded) { while (node.parent != null) { nodes[node.parent].state.expanded = true; - node = nodes[node.parent]; + data[data.indexOf(node)] = nodes[node.parent]; } } diff --git a/src/frontend/src/components/editors/TemplateEditor/PdfPreview/PdfPreview.tsx b/src/frontend/src/components/editors/TemplateEditor/PdfPreview/PdfPreview.tsx index c38e65f8a0..c0e48ae0a5 100644 --- a/src/frontend/src/components/editors/TemplateEditor/PdfPreview/PdfPreview.tsx +++ b/src/frontend/src/components/editors/TemplateEditor/PdfPreview/PdfPreview.tsx @@ -81,7 +81,9 @@ export const PdfPreviewComponent: PreviewAreaComponent = forwardRef( Preview not available, click "Reload Preview". )} - {pdfUrl &&