-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b497c54
commit 099c7b6
Showing
1 changed file
with
11 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
# Class to access the meta data field in InvenTree. The wrappers build | ||
# a dict with plugin name so that the data from different plugins does | ||
# not overlap | ||
|
||
class MetaAccess(): | ||
|
||
def get_value(self, inventree_object, app, key): | ||
def get_value(self, inventree_object, key): | ||
try: | ||
value = inventree_object.metadata[app][key] | ||
value = inventree_object.metadata[self.NAME][key] | ||
except Exception: | ||
value = None | ||
print('<----', app, key, value) | ||
return (value) | ||
|
||
def set_value(self, inventree_object, app, key, value): | ||
print('---->', app, key, value) | ||
def set_value(self, inventree_object, key, value): | ||
data = inventree_object.metadata | ||
if data is None: | ||
data = {} | ||
print('out ', data) | ||
if app in data: | ||
app_data = data[app] | ||
if self.NAME in data: | ||
app_data = data[self.NAME] | ||
app_data.update({key: value}) | ||
data.update({app: app_data}) | ||
data.update({self.NAME: app_data}) | ||
else: | ||
data.update({app: {key: value}}) | ||
print('changed', data) | ||
data.update({self.NAME: {key: value}}) | ||
inventree_object.metadata = data | ||
inventree_object.save() |