Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1221 from pypeclub/feature/store_settings_as_dict
Browse files Browse the repository at this point in the history
Settings in mongo as dict
  • Loading branch information
mkolar authored Mar 31, 2021
2 parents 4c44d42 + f8a220d commit 7f49d49
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pype/settings/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,15 @@ def update_data(self, data):
self.creation_time = datetime.datetime.now()

def update_from_document(self, document):
value = "{}"
data = {}
if document:
value = document.get("value") or value
self.data = json.loads(value)
if "data" in document:
data = document["data"]
elif "value" in document:
value = document["value"]
if value:
data = json.loads(value)
self.data = data

def to_json_string(self):
return json.dumps(self.data or {})
Expand Down Expand Up @@ -415,7 +420,7 @@ def save_studio_settings(self, data):
},
{
"type": SYSTEM_SETTINGS_KEY,
"value": self.system_settings_cache.to_json_string()
"data": self.system_settings_cache.data
},
upsert=True
)
Expand Down Expand Up @@ -550,7 +555,7 @@ def _save_project_data(self, project_name, doc_type, data_cache):
}
replace_data = {
"type": doc_type,
"value": data_cache.to_json_string(),
"data": data_cache.data,
"is_default": is_default
}
if not is_default:
Expand Down Expand Up @@ -733,7 +738,7 @@ def save_local_settings(self, data):
{
"type": LOCAL_SETTING_KEY,
"site_id": self.local_site_id,
"value": self.local_settings_cache.to_json_string()
"data": self.local_settings_cache.data
},
upsert=True
)
Expand Down

0 comments on commit 7f49d49

Please sign in to comment.