2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-11 15:34:15 +00:00

Fix email notification setting (#3832)

* Coerce setting value to a boolean

* Ignore inactive users when sending notification emails

* Only send UI notifications to active users

* Fixes for unit tests
This commit is contained in:
Oliver
2022-10-22 18:56:38 +11:00
committed by GitHub
parent c120de90ae
commit a898ebce40
6 changed files with 24 additions and 9 deletions

View File

@ -6,6 +6,7 @@ from django.utils.translation import gettext_lazy as _
from allauth.account.models import EmailAddress
import common.models
import InvenTree.helpers
import InvenTree.tasks
from plugin import InvenTreePlugin
from plugin.mixins import BulkNotificationMethod, SettingsMixin
@ -61,7 +62,12 @@ class CoreNotificationsPlugin(SettingsMixin, InvenTreePlugin):
allowed_users = []
for user in self.targets:
allows_emails = self.usersetting(user)
if not user.is_active:
# Ignore any users who have been deactivated
continue
allows_emails = InvenTree.helpers.str2bool(self.usersetting(user))
if allows_emails:
allowed_users.append(user)