| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Handles requests to the findit config page.""" | 5 """Handles requests to the findit config page.""" |
| 6 | 6 |
| 7 import json | 7 import json |
| 8 | 8 |
| 9 from base_handler import BaseHandler | 9 from base_handler import BaseHandler |
| 10 from base_handler import Permission | 10 from base_handler import Permission |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 if validation_function is None or not validation_function(configuration): | 92 if validation_function is None or not validation_function(configuration): |
| 93 return False | 93 return False |
| 94 | 94 |
| 95 return True | 95 return True |
| 96 | 96 |
| 97 | 97 |
| 98 class Configuration(BaseHandler): | 98 class Configuration(BaseHandler): |
| 99 PERMISSION_LEVEL = Permission.ADMIN | 99 PERMISSION_LEVEL = Permission.ADMIN |
| 100 | 100 |
| 101 def HandleGet(self): | 101 def HandleGet(self): |
| 102 settings = wf_config.Settings() | 102 settings = wf_config.FinditConfig.Get() |
| 103 | 103 |
| 104 data = { | 104 data = { |
| 105 'masters': settings.masters_to_blacklisted_steps, | 105 'masters': settings.masters_to_blacklisted_steps, |
| 106 'builders': settings.builders_to_trybots, | 106 'builders': settings.builders_to_trybots, |
| 107 'version': settings.VersionNumber, | 107 'version': settings.version, |
| 108 } | 108 } |
| 109 | 109 |
| 110 return {'template': 'config.html', 'data': data} | 110 return {'template': 'config.html', 'data': data} |
| 111 | 111 |
| 112 def HandlePost(self): | 112 def HandlePost(self): |
| 113 data = self.request.params.get('data') | 113 data = self.request.params.get('data') |
| 114 new_config_dict = json.loads(data) | 114 new_config_dict = json.loads(data) |
| 115 | 115 |
| 116 if not _ConfigurationDictIsValid(new_config_dict): # pragma: no cover | 116 if not _ConfigurationDictIsValid(new_config_dict): # pragma: no cover |
| 117 return self.CreateError( | 117 return self.CreateError( |
| 118 'New configuration settings is not properly formatted.', 400) | 118 'New configuration settings is not properly formatted.', 400) |
| 119 | 119 |
| 120 wf_config.Update(new_config_dict) | 120 wf_config.FinditConfig.Get().Update(**new_config_dict) |
| 121 | 121 |
| 122 return self.HandleGet() | 122 return self.HandleGet() |
| OLD | NEW |