diff --git a/src/backend/InvenTree/InvenTree/api.py b/src/backend/InvenTree/InvenTree/api.py index e8e4b847bb..7213f78cbd 100644 --- a/src/backend/InvenTree/InvenTree/api.py +++ b/src/backend/InvenTree/InvenTree/api.py @@ -26,7 +26,7 @@ from part.models import Part from plugin.serializers import MetadataSerializer from users.models import ApiToken -from .email import is_email_configured +from .helpers_email import is_email_configured from .mixins import ListAPI, RetrieveUpdateAPI from .status import check_system_health, is_worker_running from .version import inventreeApiText diff --git a/src/backend/InvenTree/InvenTree/context.py b/src/backend/InvenTree/InvenTree/context.py index 8d30e6bb8a..5a5cb6bb78 100644 --- a/src/backend/InvenTree/InvenTree/context.py +++ b/src/backend/InvenTree/InvenTree/context.py @@ -1,6 +1,6 @@ """Provides extra global data to all templates.""" -import InvenTree.email +import InvenTree.helpers_email import InvenTree.status from generic.states import StatusCode from InvenTree.helpers import inheritors @@ -25,7 +25,7 @@ def health_status(request): status = { 'django_q_running': InvenTree.status.is_worker_running(), - 'email_configured': InvenTree.email.is_email_configured(), + 'email_configured': InvenTree.helpers_email.is_email_configured(), } # The following keys are required to denote system health diff --git a/src/backend/InvenTree/InvenTree/email.py b/src/backend/InvenTree/InvenTree/helpers_email.py similarity index 100% rename from src/backend/InvenTree/InvenTree/email.py rename to src/backend/InvenTree/InvenTree/helpers_email.py diff --git a/src/backend/InvenTree/InvenTree/status.py b/src/backend/InvenTree/InvenTree/status.py index a5c9f3961c..8ca7611007 100644 --- a/src/backend/InvenTree/InvenTree/status.py +++ b/src/backend/InvenTree/InvenTree/status.py @@ -9,7 +9,7 @@ from django.utils.translation import gettext_lazy as _ from django_q.models import Success from django_q.status import Stat -import InvenTree.email +import InvenTree.helpers_email import InvenTree.ready logger = logging.getLogger('inventree') @@ -64,7 +64,7 @@ def check_system_health(**kwargs): result = False logger.warning(_('Background worker check failed')) - if not InvenTree.email.is_email_configured(): # pragma: no cover + if not InvenTree.helpers_email.is_email_configured(): # pragma: no cover result = False logger.warning(_('Email backend not configured')) diff --git a/src/backend/InvenTree/build/tasks.py b/src/backend/InvenTree/build/tasks.py index 82828d642d..6793ae03bb 100644 --- a/src/backend/InvenTree/build/tasks.py +++ b/src/backend/InvenTree/build/tasks.py @@ -1,34 +1,31 @@ -"""Background task definitions for the BuildOrder app""" +"""Background task definitions for the BuildOrder app.""" +import logging from datetime import timedelta from decimal import Decimal -import logging from django.contrib.auth.models import User -from django.utils.translation import gettext_lazy as _ from django.template.loader import render_to_string +from django.utils.translation import gettext_lazy as _ from allauth.account.models import EmailAddress -from plugin.events import trigger_event -import common.notifications import build.models -import InvenTree.email +import common.notifications import InvenTree.helpers +import InvenTree.helpers_email import InvenTree.helpers_model import InvenTree.tasks -from InvenTree.ready import isImportingData -from build.status_codes import BuildStatusGroups - import part.models as part_models - +from build.status_codes import BuildStatusGroups +from InvenTree.ready import isImportingData +from plugin.events import trigger_event logger = logging.getLogger('inventree') def auto_allocate_build(build_id: int, **kwargs): """Run auto-allocation for a specified BuildOrder.""" - build_order = build.models.Build.objects.filter(pk=build_id).first() if not build_order: @@ -40,7 +37,6 @@ def auto_allocate_build(build_id: int, **kwargs): def complete_build_allocations(build_id: int, user_id: int): """Complete build allocations for a specified BuildOrder.""" - build_order = build.models.Build.objects.filter(pk=build_id).first() if user_id: @@ -185,11 +181,11 @@ def check_build_stock(build: build.models.Build): recipients = emails.values_list('email', flat=True) - InvenTree.email.send_email(subject, '', recipients, html_message=html_message) + InvenTree.helpers_email.send_email(subject, '', recipients, html_message=html_message) def notify_overdue_build_order(bo: build.models.Build): - """Notify appropriate users that a Build has just become 'overdue'""" + """Notify appropriate users that a Build has just become 'overdue'.""" targets = [] if bo.issued_by: @@ -229,7 +225,7 @@ def notify_overdue_build_order(bo: build.models.Build): @InvenTree.tasks.scheduled_task(InvenTree.tasks.ScheduledTask.DAILY) def check_overdue_build_orders(): - """Check if any outstanding BuildOrders have just become overdue + """Check if any outstanding BuildOrders have just become overdue. - This check is performed daily - Look at the 'target_date' of any outstanding BuildOrder objects diff --git a/src/backend/InvenTree/generic/states/states.py b/src/backend/InvenTree/generic/states/states.py index 83342aed42..b0a0a0c669 100644 --- a/src/backend/InvenTree/generic/states/states.py +++ b/src/backend/InvenTree/generic/states/states.py @@ -4,7 +4,7 @@ import enum import re -class BaseEnum(enum.IntEnum): +class BaseEnum(enum.IntEnum): # noqa: PLW1641 """An `Enum` capabile of having its members have docstrings. Based on https://stackoverflow.com/questions/19330460/how-do-i-put-docstrings-on-enums diff --git a/src/backend/InvenTree/plugin/builtin/integration/core_notifications.py b/src/backend/InvenTree/plugin/builtin/integration/core_notifications.py index 298677c4ec..d0ac96a08d 100644 --- a/src/backend/InvenTree/plugin/builtin/integration/core_notifications.py +++ b/src/backend/InvenTree/plugin/builtin/integration/core_notifications.py @@ -7,8 +7,8 @@ import requests from allauth.account.models import EmailAddress import common.models -import InvenTree.email import InvenTree.helpers +import InvenTree.helpers_email import InvenTree.tasks from plugin import InvenTreePlugin, registry from plugin.mixins import BulkNotificationMethod, SettingsContentMixin, SettingsMixin @@ -116,7 +116,9 @@ class InvenTreeCoreNotificationsPlugin( if instance_title: subject = f'[{instance_title}] {subject}' - InvenTree.email.send_email(subject, '', targets, html_message=html_message) + InvenTree.helpers_email.send_email( + subject, '', targets, html_message=html_message + ) return True