mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
refactor clean method to reduce duplication
This commit is contained in:
parent
8d01df0b5e
commit
205916e0b2
@ -112,6 +112,17 @@ class GenericSettingClassMixin:
|
||||
self.REFERENCE_NAME: getattr(self, self.REFERENCE_NAME)
|
||||
}
|
||||
|
||||
"""
|
||||
We override the following class methods,
|
||||
so that we can pass the modified key instance as an additional argument
|
||||
"""
|
||||
|
||||
def clean(self, **kwargs):
|
||||
|
||||
kwargs[self.REFERENCE_NAME] = getattr(self, self.REFERENCE_NAME)
|
||||
|
||||
super().clean(**kwargs)
|
||||
|
||||
def is_bool(self, **kwargs):
|
||||
|
||||
kwargs[self.REFERENCE_NAME] = getattr(self, self.REFERENCE_NAME)
|
||||
@ -148,17 +159,6 @@ class PluginSetting(GenericSettingClassMixin, common.models.BaseInvenTreeSetting
|
||||
('plugin', 'key'),
|
||||
]
|
||||
|
||||
def clean(self, **kwargs):
|
||||
|
||||
kwargs['plugin'] = self.plugin
|
||||
|
||||
super().clean(**kwargs)
|
||||
|
||||
"""
|
||||
We override the following class methods,
|
||||
so that we can pass the plugin instance
|
||||
"""
|
||||
|
||||
REFERENCE_NAME = 'plugin'
|
||||
|
||||
@classmethod
|
||||
@ -208,17 +208,6 @@ class NotificationUserSetting(common.models.BaseInvenTreeSetting):
|
||||
('method', 'user', 'key'),
|
||||
]
|
||||
|
||||
def clean(self, **kwargs):
|
||||
|
||||
kwargs['method'] = self.method
|
||||
|
||||
super().clean(**kwargs)
|
||||
|
||||
"""
|
||||
We override the following class methods,
|
||||
so that we can pass the method instance
|
||||
"""
|
||||
|
||||
REFERENCE_NAME = 'method'
|
||||
|
||||
@classmethod
|
||||
|
Loading…
Reference in New Issue
Block a user