| 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 |
| 11 from model import wf_config | 11 from model import wf_config |
| 12 from waterfall import waterfall_config | 12 from waterfall import waterfall_config |
| 13 | 13 |
| 14 from google.appengine.api import users |
| 15 |
| 14 | 16 |
| 15 def _RemoveDuplicatesAndSort(elements): | 17 def _RemoveDuplicatesAndSort(elements): |
| 16 return list(set(elements)) | 18 return list(set(elements)) |
| 17 | 19 |
| 18 | 20 |
| 19 def _IsListOfType(elements, element_type): | 21 def _IsListOfType(elements, element_type): |
| 20 """Determines whether or not elements is a list of unique elements of type.""" | 22 """Determines whether or not elements is a list of unique elements of type.""" |
| 21 if not elements or not isinstance(elements, list): | 23 if not elements or not isinstance(elements, list): |
| 22 return False | 24 return False |
| 23 | 25 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 238 |
| 237 return {'template': 'config.html', 'data': data} | 239 return {'template': 'config.html', 'data': data} |
| 238 | 240 |
| 239 def HandlePost(self): | 241 def HandlePost(self): |
| 240 data = self.request.params.get('data') | 242 data = self.request.params.get('data') |
| 241 new_config_dict = json.loads(data) | 243 new_config_dict = json.loads(data) |
| 242 if not _ConfigurationDictIsValid(new_config_dict): # pragma: no cover | 244 if not _ConfigurationDictIsValid(new_config_dict): # pragma: no cover |
| 243 return self.CreateError( | 245 return self.CreateError( |
| 244 'New configuration settings is not properly formatted.', 400) | 246 'New configuration settings is not properly formatted.', 400) |
| 245 | 247 |
| 246 wf_config.FinditConfig.Get().Update(**new_config_dict) | 248 wf_config.FinditConfig.Get().Update(users.get_current_user(), |
| 249 users.IsCurrentUserAdmin(), |
| 250 **new_config_dict) |
| 247 | 251 |
| 248 return self.HandleGet() | 252 return self.HandleGet() |
| OLD | NEW |