mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	Various SAST fixes (#7644)
* cleanup auth * clean Unexpected empty object pattern * clenaup empty object patterns * fix identical sub-expressions * fix missing title on iframe * Do not pass children as props * update node assigment * fix typing * fix variables that shadow builtins * revert StylishText change
This commit is contained in:
		| @@ -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") | ||||
|  | ||||
|   | ||||
| @@ -39,7 +39,7 @@ def qrcode(data, **kwargs): | ||||
|     fill_color = kwargs.pop('fill_color', 'black') | ||||
|     back_color = kwargs.pop('back_color', 'white') | ||||
|  | ||||
|     format = kwargs.pop('format', 'PNG') | ||||
|     img_format = kwargs.pop('format', 'PNG') | ||||
|  | ||||
|     params.update(**kwargs) | ||||
|  | ||||
| @@ -51,7 +51,7 @@ def qrcode(data, **kwargs): | ||||
|     qri = qr.make_image(fill_color=fill_color, back_color=back_color) | ||||
|  | ||||
|     # Render to byte-encoded image | ||||
|     return image_data(qri, fmt=format) | ||||
|     return image_data(qri, fmt=img_format) | ||||
|  | ||||
|  | ||||
| @register.simple_tag() | ||||
| @@ -59,7 +59,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) | ||||
|  | ||||
| @@ -70,4 +70,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) | ||||
|   | ||||
| @@ -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]; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user