mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Optional error notification (#5506)
* Add user setting for receiving error notifications * Ignore uses who don't want error notifications * Add config to settings page
This commit is contained in:
parent
2243f288ee
commit
f917c91522
@ -887,6 +887,7 @@ def after_error_logged(sender, instance: Error, created: bool, **kwargs):
|
|||||||
|
|
||||||
if created:
|
if created:
|
||||||
try:
|
try:
|
||||||
|
import common.models
|
||||||
import common.notifications
|
import common.notifications
|
||||||
|
|
||||||
users = get_user_model().objects.filter(is_staff=True)
|
users = get_user_model().objects.filter(is_staff=True)
|
||||||
@ -902,6 +903,13 @@ def after_error_logged(sender, instance: Error, created: bool, **kwargs):
|
|||||||
'link': link
|
'link': link
|
||||||
}
|
}
|
||||||
|
|
||||||
|
target_users = []
|
||||||
|
|
||||||
|
for user in users:
|
||||||
|
if common.models.InvenTreeUserSetting.get_setting('NOTIFICATION_ERROR_REPORT', True, user=user):
|
||||||
|
target_users.append(user)
|
||||||
|
|
||||||
|
if len(target_users) > 0:
|
||||||
common.notifications.trigger_notification(
|
common.notifications.trigger_notification(
|
||||||
instance,
|
instance,
|
||||||
'inventree.error_log',
|
'inventree.error_log',
|
||||||
|
@ -2191,6 +2191,13 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
|
|||||||
'default': '',
|
'default': '',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'NOTIFICATION_ERROR_REPORT': {
|
||||||
|
'name': _('Receive error reports'),
|
||||||
|
'description': _('Receive notifications for system errors'),
|
||||||
|
'default': True,
|
||||||
|
'validator': bool,
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typ = 'user'
|
typ = 'user'
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
<div class='row'>
|
<div class='row'>
|
||||||
<table class='table table-striped table-condensed'>
|
<table class='table table-striped table-condensed'>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
{% if user.is_staff %}
|
||||||
|
{% include "InvenTree/settings/setting.html" with key="NOTIFICATION_ERROR_REPORT" icon='fa-flag' user_setting=True %}
|
||||||
|
{% endif %}
|
||||||
{% notification_settings_list as settings %}
|
{% notification_settings_list as settings %}
|
||||||
{% for setting in settings %}
|
{% for setting in settings %}
|
||||||
{% include "InvenTree/settings/setting.html" with key=setting.key icon=setting.icon method=setting.method notification_setting=True %}
|
{% include "InvenTree/settings/setting.html" with key=setting.key icon=setting.icon method=setting.method notification_setting=True %}
|
||||||
|
Loading…
Reference in New Issue
Block a user