2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-03 12:10:59 +00:00

Refctor image downloader (#3393)

* Adds configurable setting for maximum remote image size

* Add helper function for downloading image from remote URL

- Will replace existing function
- Performs more thorough sanity checking

* Replace existing image downloading code

- part image uses new generic function
- company image uses new generic function

* Rearrange settings

* Refactor and cleanup existing views / forms

* Add unit testing for image downloader function

* Refactor image downloader forms

- Part image download now uses the API
- Company image download now uses the API
- Remove outdated forms / views / templates

* Increment API version

* Prevent remote image download via API if the setting is not enabled

* Do not attempt to validate or extract image from blank URL

* Fix custom save() serializer methods
This commit is contained in:
Oliver
2022-07-25 11:17:59 +10:00
committed by GitHub
parent d32054b53b
commit eecb26676e
18 changed files with 279 additions and 301 deletions

View File

@ -24,7 +24,8 @@ from django.contrib.humanize.templatetags.humanize import naturaltime
from django.contrib.sites.models import Site
from django.core.cache import cache
from django.core.exceptions import AppRegistryNotReady, ValidationError
from django.core.validators import MinValueValidator, URLValidator
from django.core.validators import (MaxValueValidator, MinValueValidator,
URLValidator)
from django.db import models, transaction
from django.db.utils import IntegrityError, OperationalError
from django.urls import reverse
@ -856,6 +857,18 @@ class InvenTreeSetting(BaseInvenTreeSetting):
'default': False,
},
'INVENTREE_DOWNLOAD_IMAGE_MAX_SIZE': {
'name': _('Download Size Limit'),
'description': _('Maximum allowable download size for remote image'),
'units': 'MB',
'default': 1,
'validator': [
int,
MinValueValidator(1),
MaxValueValidator(25),
]
},
'INVENTREE_REQUIRE_CONFIRM': {
'name': _('Require confirm'),
'description': _('Require explicit user confirmation for certain action.'),