OLD | NEW |
1 # Copyright 2013 Google Inc. | 1 # Copyright 2013 Google Inc. |
2 # | 2 # |
3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
6 # | 6 # |
7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
8 # | 8 # |
9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 # See the License for the specific language governing permissions and | 12 # See the License for the specific language governing permissions and |
13 # limitations under the License. | 13 # limitations under the License. |
14 | 14 |
15 from . import library | 15 from . import library |
16 from . import models | 16 from . import models |
17 from .common import IS_DEV | 17 from .common import IS_DEV |
18 | 18 |
19 from google.appengine.api import users | 19 from google.appengine.api import users |
20 | 20 |
21 from django.conf import settings as django_settings | 21 from django.conf import settings as django_settings |
22 from django.http import HttpResponse | 22 from django.http import HttpResponse |
23 from django.shortcuts import render_to_response | 23 from django.shortcuts import render_to_response |
24 from django.template import RequestContext | 24 from django.template import RequestContext |
25 | 25 |
| 26 from codereview import auth_utils |
| 27 from codereview import buildbucket |
| 28 from codereview import common |
| 29 |
26 | 30 |
27 # Counter displayed (by respond()) below) on every page showing how | 31 # Counter displayed (by respond()) below) on every page showing how |
28 # many requests the current incarnation has handled, not counting | 32 # many requests the current incarnation has handled, not counting |
29 # redirects. Rendered by templates/base.html. | 33 # redirects. Rendered by templates/base.html. |
30 COUNTER = 0 | 34 COUNTER = 0 |
31 | 35 |
32 | 36 |
33 class HttpTextResponse(HttpResponse): | 37 class HttpTextResponse(HttpResponse): |
34 def __init__(self, *args, **kwargs): | 38 def __init__(self, *args, **kwargs): |
35 kwargs['content_type'] = 'text/plain; charset=utf-8' | 39 kwargs['content_type'] = 'text/plain; charset=utf-8' |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 full_path = request.get_full_path().encode('utf-8') | 80 full_path = request.get_full_path().encode('utf-8') |
77 if request.user is None: | 81 if request.user is None: |
78 params['sign_in'] = users.create_login_url(full_path) | 82 params['sign_in'] = users.create_login_url(full_path) |
79 else: | 83 else: |
80 params['sign_out'] = users.create_logout_url(full_path) | 84 params['sign_out'] = users.create_logout_url(full_path) |
81 account = models.Account.current_user_account | 85 account = models.Account.current_user_account |
82 if account is not None: | 86 if account is not None: |
83 params['xsrf_token'] = account.get_xsrf_token() | 87 params['xsrf_token'] = account.get_xsrf_token() |
84 params['must_choose_nickname'] = must_choose_nickname | 88 params['must_choose_nickname'] = must_choose_nickname |
85 params['rietveld_revision'] = django_settings.RIETVELD_REVISION | 89 params['rietveld_revision'] = django_settings.RIETVELD_REVISION |
| 90 params['preferred_domain_name'] = common.get_preferred_domain_name() |
| 91 params['buildbucket_hostname'] = buildbucket.BUILDBUCKET_HOSTNAME |
| 92 params['client_id'] = auth_utils.get_own_web_client_id() |
86 try: | 93 try: |
87 return render_to_response(template, params, | 94 return render_to_response(template, params, |
88 context_instance=RequestContext(request)) | 95 context_instance=RequestContext(request)) |
89 finally: | 96 finally: |
90 library.user_cache.clear() # don't want this sticking around | 97 library.user_cache.clear() # don't want this sticking around |
OLD | NEW |