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

Settings in mongo as dict #1221

Merged
merged 1 commit into from
Mar 31, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -730,7 +735,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