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:
|
||||
try:
|
||||
import common.models
|
||||
import common.notifications
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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(
|
||||
instance,
|
||||
'inventree.error_log',
|
||||
|
@ -2191,6 +2191,13 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
|
||||
'default': '',
|
||||
},
|
||||
|
||||
'NOTIFICATION_ERROR_REPORT': {
|
||||
'name': _('Receive error reports'),
|
||||
'description': _('Receive notifications for system errors'),
|
||||
'default': True,
|
||||
'validator': bool,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
typ = 'user'
|
||||
|
@ -13,6 +13,9 @@
|
||||
<div class='row'>
|
||||
<table class='table table-striped table-condensed'>
|
||||
<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 %}
|
||||
{% for setting in settings %}
|
||||
{% 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