Skip to content

Commit

Permalink
Merge branch 'master' into add-selectionList
Browse files Browse the repository at this point in the history
  • Loading branch information
matmair authored Oct 24, 2024
2 parents 2205d05 + 6bf9a97 commit 72a81d5
Show file tree
Hide file tree
Showing 112 changed files with 138,118 additions and 127,146 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Build frontend
run: cd src/frontend && npm run compile && npm run build
- name: Create SBOM for frontend
uses: anchore/sbom-action@f5e124a5e5e1d497a692818ae907d3c45829d033 # pin@v0
uses: anchore/sbom-action@8d0a6505bf28ced3e85154d13dc6af83299e13f1 # pin@v0
with:
artifact-name: frontend-build.spdx
path: src/frontend
Expand Down
212 changes: 111 additions & 101 deletions contrib/container/requirements.txt

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,13 @@ mkdocs-include-markdown-plugin==6.2.2 \
--hash=sha256:d293950f6499d2944291ca7b9bc4a60e652bbfd3e3a42b564f6cceee268694e7 \
--hash=sha256:f2bd5026650492a581d2fd44be6c22f90391910d76582b96a34c264f2d17875d
# via -r docs/requirements.in
mkdocs-macros-plugin==1.3.5 \
--hash=sha256:58bd47ea7097d1a2824dc9d0d912c211823c5e6e6fe8a19a3ecf33346f7d6547 \
--hash=sha256:5fd6969e2c43e23031ffb719bebe7421163ea26f4dc360af2343144ca979b04b
mkdocs-macros-plugin==1.3.6 \
--hash=sha256:074bc072cac14c28724037b6988743cd9425752bdd35ae05fbf96b1b2457f3b7 \
--hash=sha256:74fd418c8e1f9f021b7a45bb1c7d7461d8ae09ccec241787f3971e733374da8c
# via -r docs/requirements.in
mkdocs-material==9.5.40 \
--hash=sha256:8e7a16ada34e79a7b6459ff2602584222f522c738b6a023d1bea853d5049da6f \
--hash=sha256:b69d70e667ec51fc41f65e006a3184dd00d95b2439d982cb1586e4c018943156
mkdocs-material==9.5.42 \
--hash=sha256:452a7c5d21284b373f36b981a2cbebfff59263feebeede1bc28652e9c5bbe316 \
--hash=sha256:92779b5e9b5934540c574c11647131d217dc540dce72b05feeda088c8eb1b8f2
# via -r docs/requirements.in
mkdocs-material-extensions==1.3.1 \
--hash=sha256:10c9511cea88f568257f960358a467d12b970e1f7b2c0e5fb2bb48cab1928443 \
Expand Down
1 change: 1 addition & 0 deletions src/backend/InvenTree/InvenTree/helpers_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ def send_email(subject, body, recipients, from_email=None, html_message=None):
recipients,
fail_silently=False,
html_message=html_message,
group='notification',
)
5 changes: 4 additions & 1 deletion src/backend/InvenTree/InvenTree/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ def offload_task(
"""
from InvenTree.exceptions import log_error

# Extract group information from kwargs
group = kwargs.pop('group', 'inventree')

try:
import importlib

Expand All @@ -200,7 +203,7 @@ def offload_task(
if force_async or (is_worker_running() and not force_sync):
# Running as asynchronous task
try:
task = AsyncTask(taskname, *args, **kwargs)
task = AsyncTask(taskname, *args, group=group, **kwargs)
task.run()
except ImportError:
raise_warning(f"WARNING: '{taskname}' not offloaded - Function not found")
Expand Down
12 changes: 9 additions & 3 deletions src/backend/InvenTree/build/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,8 @@ def _action_complete(self, *args, **kwargs):
if not InvenTree.tasks.offload_task(
build.tasks.complete_build_allocations,
self.pk,
user.pk if user else None
user.pk if user else None,
group='build'
):
raise ValidationError(_("Failed to offload task to complete build allocations"))

Expand Down Expand Up @@ -772,7 +773,8 @@ def _action_cancel(self, *args, **kwargs):
if not InvenTree.tasks.offload_task(
build.tasks.complete_build_allocations,
self.pk,
user.pk if user else None
user.pk if user else None,
group='build',
):
raise ValidationError(_("Failed to offload task to complete build allocations"))

Expand Down Expand Up @@ -1441,7 +1443,11 @@ def after_save_build(sender, instance: Build, created: bool, **kwargs):
instance.create_build_line_items()

# Run checks on required parts
InvenTree.tasks.offload_task(build_tasks.check_build_stock, instance)
InvenTree.tasks.offload_task(
build_tasks.check_build_stock,
instance,
group='build'
)

# Notify the responsible users that the build order has been created
InvenTree.helpers_model.notify_responsible(instance, sender, exclude=instance.issued_by)
Expand Down
4 changes: 3 additions & 1 deletion src/backend/InvenTree/build/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def create(self, validated_data):
InvenTree.tasks.offload_task(
build.tasks.create_child_builds,
build_order.pk,
group='build',
)

return build_order
Expand Down Expand Up @@ -1134,7 +1135,8 @@ def save(self):
exclude_location=data.get('exclude_location', None),
interchangeable=data['interchangeable'],
substitutes=data['substitutes'],
optional_items=data['optional_items']
optional_items=data['optional_items'],
group='build'
):
raise ValidationError(_("Failed to start auto-allocation task"))

Expand Down
3 changes: 2 additions & 1 deletion src/backend/InvenTree/build/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ def create_child_builds(build_id: int) -> None:
# Offload the child build order creation to the background task queue
InvenTree.tasks.offload_task(
create_child_builds,
sub_order.pk
sub_order.pk,
group='build'
)


Expand Down
4 changes: 3 additions & 1 deletion src/backend/InvenTree/common/currency.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ def after_change_currency(setting) -> None:
InvenTree.tasks.update_exchange_rates(force=True)

# Offload update of part prices to a background task
InvenTree.tasks.offload_task(part_tasks.check_missing_pricing, force_async=True)
InvenTree.tasks.offload_task(
part_tasks.check_missing_pricing, force_async=True, group='pricing'
)


def validate_currency_codes(value):
Expand Down
59 changes: 57 additions & 2 deletions src/backend/InvenTree/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,9 @@ def clean(self):
elif self.is_bool():
self.value = self.as_bool()

elif self.is_float():
self.value = self.as_float()

validator = self.__class__.get_setting_validator(
self.key, **self.get_filters_for_instance()
)
Expand Down Expand Up @@ -862,6 +865,14 @@ def run_validator(self, validator):
except (ValueError, TypeError):
raise ValidationError({'value': _('Value must be an integer value')})

# Floating point validator
if validator is float:
try:
# Coerce into a floating point value
value = float(value)
except (ValueError, TypeError):
raise ValidationError({'value': _('Value must be a valid number')})

# If a list of validators is supplied, iterate through each one
if type(validator) in [list, tuple]:
for v in validator:
Expand All @@ -873,10 +884,18 @@ def run_validator(self, validator):
if self.is_bool():
value = self.as_bool()

if self.is_int():
elif self.is_int():
value = self.as_int()

validator(value)
elif self.is_float():
value = self.as_float()

try:
validator(value)
except ValidationError as e:
raise e
except Exception:
raise ValidationError({'value': _('Invalid value')})

def validate_unique(self, exclude=None):
"""Ensure that the key:value pair is unique. In addition to the base validators, this ensures that the 'key' is unique, using a case-insensitive comparison.
Expand Down Expand Up @@ -970,6 +989,9 @@ def model_class(self):
if not model_name:
return None

# Enforce lower-case model name
model_name = str(model_name).strip().lower()

try:
(app, mdl) = model_name.strip().split('.')
except ValueError:
Expand Down Expand Up @@ -1069,6 +1091,39 @@ def validator_is_bool(cls, validator):

return False

def is_float(self):
"""Check if the setting is required to be a float value."""
validator = self.__class__.get_setting_validator(
self.key, **self.get_filters_for_instance()
)

return self.__class__.validator_is_float(validator)

@classmethod
def validator_is_float(cls, validator):
"""Return if validator is for float."""
if validator == float:
return True

if type(validator) in [list, tuple]:
for v in validator:
if v == float:
return True

return False

def as_float(self):
"""Return the value of this setting converted to a float value.
If an error occurs, return the default value
"""
try:
value = float(self.value)
except (ValueError, TypeError):
value = self.default_value

return value

def is_int(self):
"""Check if the setting is required to be an integer value."""
validator = self.__class__.get_setting_validator(
Expand Down
Loading

0 comments on commit 72a81d5

Please sign in to comment.