| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import collections | 5 import collections |
| 6 import json | 6 import json |
| 7 import logging | 7 import logging |
| 8 | 8 |
| 9 from google.appengine.api import users | 9 from google.appengine.api import users |
| 10 import jinja2 | 10 import jinja2 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 elif self.PERMISSION_LEVEL == Permission.ADMIN: | 51 elif self.PERMISSION_LEVEL == Permission.ADMIN: |
| 52 return auth_util.IsCurrentUserAdmin() | 52 return auth_util.IsCurrentUserAdmin() |
| 53 else: | 53 else: |
| 54 logging.error('Unknown permission level: %s' % self.PERMISSION_LEVEL) | 54 logging.error('Unknown permission level: %s' % self.PERMISSION_LEVEL) |
| 55 return False | 55 return False |
| 56 | 56 |
| 57 def IsCorpUserOrAdmin(self): | 57 def IsCorpUserOrAdmin(self): |
| 58 """Returns True if the user logged in with corp account or as admin.""" | 58 """Returns True if the user logged in with corp account or as admin.""" |
| 59 user_email = auth_util.GetUserEmail() | 59 user_email = auth_util.GetUserEmail() |
| 60 return ((user_email and user_email.endswith('@google.com')) or | 60 return ((user_email and user_email.endswith('@google.com')) or |
| 61 auth_util.IsCurrentUserAdmin()) | 61 auth_util.IsCurrentUserAdmin()) |
| 62 |
| 63 def _ShowDebugInfo(self): |
| 64 # Show debug info only if the app is run locally during development, if the |
| 65 # currently logged-in user is an admin, or if it is explicitly requested |
| 66 # with parameter 'debug=1'. |
| 67 return users.is_current_user_admin() or self.request.get('debug') == '1' |
| 62 | 68 |
| 63 @staticmethod | 69 @staticmethod |
| 64 def CreateError(error_message, return_code=500): | 70 def CreateError(error_message, return_code=500): |
| 65 logging.error('Error occurred: %s', error_message) | 71 logging.error('Error occurred: %s', error_message) |
| 66 return { | 72 return { |
| 67 'template': 'error.html', | 73 'template': 'error.html', |
| 68 'data': {'error_message': error_message}, | 74 'data': {'error_message': error_message}, |
| 69 'return_code': return_code, | 75 'return_code': return_code, |
| 70 } | 76 } |
| 71 | 77 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 return_code = 500 | 185 return_code = 500 |
| 180 cache_expiry = None | 186 cache_expiry = None |
| 181 | 187 |
| 182 self._SendResponse(template, data, return_code, cache_expiry) | 188 self._SendResponse(template, data, return_code, cache_expiry) |
| 183 | 189 |
| 184 def get(self): | 190 def get(self): |
| 185 self._Handle(self.HandleGet) | 191 self._Handle(self.HandleGet) |
| 186 | 192 |
| 187 def post(self): | 193 def post(self): |
| 188 self._Handle(self.HandlePost) | 194 self._Handle(self.HandlePost) |
| OLD | NEW |