mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
fix getattr useage
This commit is contained in:
parent
cb80c73bc6
commit
a2e54a760e
@ -336,9 +336,9 @@ def trigger_notification(obj, category=None, obj_ref='pk', **kwargs):
|
|||||||
|
|
||||||
# Try with some defaults
|
# Try with some defaults
|
||||||
if not obj_ref_value:
|
if not obj_ref_value:
|
||||||
obj_ref_value = getattr(obj, 'pk')
|
obj_ref_value = getattr(obj, 'pk', None)
|
||||||
if not obj_ref_value:
|
if not obj_ref_value:
|
||||||
obj_ref_value = getattr(obj, 'id')
|
obj_ref_value = getattr(obj, 'id', None)
|
||||||
if not obj_ref_value:
|
if not obj_ref_value:
|
||||||
raise KeyError(f"Could not resolve an object reference for '{str(obj)}' with {obj_ref}, pk, id")
|
raise KeyError(f"Could not resolve an object reference for '{str(obj)}' with {obj_ref}, pk, id")
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class APICallMixin:
|
|||||||
Check the mixin class docstring for a full example.
|
Check the mixin class docstring for a full example.
|
||||||
"""
|
"""
|
||||||
headers = {'Content-Type': 'application/json'}
|
headers = {'Content-Type': 'application/json'}
|
||||||
if getattr(self, 'API_TOKEN_SETTING'):
|
if getattr(self, 'API_TOKEN_SETTING', None):
|
||||||
token = self.get_setting(self.API_TOKEN_SETTING)
|
token = self.get_setting(self.API_TOKEN_SETTING)
|
||||||
|
|
||||||
if token:
|
if token:
|
||||||
|
@ -189,7 +189,7 @@ class PluginSetting(common.models.BaseInvenTreeSetting):
|
|||||||
plugin = kwargs.pop('plugin', None)
|
plugin = kwargs.pop('plugin', None)
|
||||||
|
|
||||||
if plugin:
|
if plugin:
|
||||||
mixin_settings = getattr(registry, 'mixins_settings')
|
mixin_settings = getattr(registry, 'mixins_settings', None)
|
||||||
if mixin_settings:
|
if mixin_settings:
|
||||||
kwargs['settings'] = mixin_settings.get(plugin.key, {})
|
kwargs['settings'] = mixin_settings.get(plugin.key, {})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user