From fdb2df2b6561caadd0471cb124b7e4a2ecdbf6c6 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 15 2015 02:56:37 +0000 Subject: Create the default dict of settings and update the current dict if needded This is useful to be able to add more settings as we want --- diff --git a/pagure/lib/model.py b/pagure/lib/model.py index 7461331..bcb02dd 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -284,14 +284,21 @@ class Project(BASE): """ Return the dict stored as string in the database as an actual dict object. """ + default = { + 'issue_tracker': True, + 'project_documentation': True, + 'pull_requests': True, + } + if self._settings: - return json.loads(self._settings) + current = json.loads(self._settings) + # Update the current dict with the new keys + for key in default: + if key not in current: + current[key] = default[key] + return current else: - return { - 'issue_tracker': True, - 'project_documentation': True, - 'pull_requests': True, - } + return default def save_settings(self, settings): ''' Ensures the settings are properly saved. '''