mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Check that notification target is not null (#3449)
* Check that target is not null * Prevent display of "negative" notification coutner * spelling fix
This commit is contained in:
parent
ee18ce9a7a
commit
6118d1319c
@ -161,8 +161,8 @@ class NotificationMessageSerializer(InvenTreeModelSerializer):
|
||||
"""Function to resolve generic object reference to target."""
|
||||
target = get_objectreference(obj, 'target_content_type', 'target_object_id')
|
||||
|
||||
if 'link' not in target:
|
||||
# Check if objekt has an absolute_url function
|
||||
if target and 'link' not in target:
|
||||
# Check if object has an absolute_url function
|
||||
if hasattr(obj.target_object, 'get_absolute_url'):
|
||||
target['link'] = obj.target_object.get_absolute_url()
|
||||
else:
|
||||
@ -174,6 +174,7 @@ class NotificationMessageSerializer(InvenTreeModelSerializer):
|
||||
f'admin:{meta.db_table}_change',
|
||||
kwargs={'object_id': obj.target_object_id}
|
||||
))
|
||||
|
||||
return target
|
||||
|
||||
def get_source(self, obj):
|
||||
|
@ -174,6 +174,12 @@ function updateNotificationReadState(btn, panel_caller=false) {
|
||||
} else {
|
||||
count = count + 1;
|
||||
}
|
||||
|
||||
// Prevent negative notification count
|
||||
if (count < 0) {
|
||||
count = 0;
|
||||
}
|
||||
|
||||
// update notification indicator now
|
||||
updateNotificationIndicator(count);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user