| OLD | NEW |
| 1 # Copyright 2008 Google Inc. | 1 # Copyright 2008 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, |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 client_id = forms.CharField( | 540 client_id = forms.CharField( |
| 541 help_text='Enter a single service account Client ID.', | 541 help_text='Enter a single service account Client ID.', |
| 542 widget=forms.TextInput(attrs={'size': '100'})) | 542 widget=forms.TextInput(attrs={'size': '100'})) |
| 543 client_secret = forms.CharField( | 543 client_secret = forms.CharField( |
| 544 required=False, | 544 required=False, |
| 545 widget=forms.TextInput(attrs={'size': '100'})) | 545 widget=forms.TextInput(attrs={'size': '100'})) |
| 546 additional_client_ids = StringListField( | 546 additional_client_ids = StringListField( |
| 547 required=False, | 547 required=False, |
| 548 help_text='Enter a comma-separated list of Client IDs.', | 548 help_text='Enter a comma-separated list of Client IDs.', |
| 549 widget=forms.TextInput(attrs={'size': '100'})) | 549 widget=forms.TextInput(attrs={'size': '100'})) |
| 550 whitelisted_emails = StringListField( |
| 551 required=False, |
| 552 help_text='Enter a comma-separated list of email addresses to whitelist.', |
| 553 widget=forms.TextInput(attrs={'size': '100'})) |
| 550 | 554 |
| 551 class UpdateStatsForm(forms.Form): | 555 class UpdateStatsForm(forms.Form): |
| 552 tasks_to_trigger = forms.CharField( | 556 tasks_to_trigger = forms.CharField( |
| 553 required=True, max_length=2000, | 557 required=True, max_length=2000, |
| 554 help_text='Coma separated items.', | 558 help_text='Coma separated items.', |
| 555 widget=forms.TextInput(attrs={'size': '100'})) | 559 widget=forms.TextInput(attrs={'size': '100'})) |
| 556 | 560 |
| 557 | 561 |
| 558 ### Exceptions ### | 562 ### Exceptions ### |
| 559 | 563 |
| (...skipping 3865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4425 from other modules. | 4429 from other modules. |
| 4426 | 4430 |
| 4427 Args: | 4431 Args: |
| 4428 django_request: Django HttpRequest object, The request. | 4432 django_request: Django HttpRequest object, The request. |
| 4429 | 4433 |
| 4430 Returns: | 4434 Returns: |
| 4431 oauth2client.client.OAuth2WebServerFlow object. | 4435 oauth2client.client.OAuth2WebServerFlow object. |
| 4432 """ | 4436 """ |
| 4433 redirect_path = reverse(oauth2callback) | 4437 redirect_path = reverse(oauth2callback) |
| 4434 redirect_uri = django_request.build_absolute_uri(redirect_path) | 4438 redirect_uri = django_request.build_absolute_uri(redirect_path) |
| 4435 client_id, client_secret, _ = auth_utils.SecretKey.get_config() | 4439 client_id, client_secret, _, _ = auth_utils.SecretKey.get_config() |
| 4436 return OAuth2WebServerFlow(client_id, client_secret, auth_utils.EMAIL_SCOPE, | 4440 return OAuth2WebServerFlow(client_id, client_secret, auth_utils.EMAIL_SCOPE, |
| 4437 redirect_uri=redirect_uri, | 4441 redirect_uri=redirect_uri, |
| 4438 approval_prompt='force') | 4442 approval_prompt='force') |
| 4439 | 4443 |
| 4440 | 4444 |
| 4441 def _validate_port(port_value): | 4445 def _validate_port(port_value): |
| 4442 """Makes sure the port value is valid and can be used by a non-root user. | 4446 """Makes sure the port value is valid and can be used by a non-root user. |
| 4443 | 4447 |
| 4444 Args: | 4448 Args: |
| 4445 port_value: Integer or string version of integer. | 4449 port_value: Integer or string version of integer. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4534 | 4538 |
| 4535 These values, from the Google APIs console, are required to validate | 4539 These values, from the Google APIs console, are required to validate |
| 4536 OAuth 2.0 tokens within auth_utils.py. | 4540 OAuth 2.0 tokens within auth_utils.py. |
| 4537 """ | 4541 """ |
| 4538 if request.method == 'POST': | 4542 if request.method == 'POST': |
| 4539 form = ClientIDAndSecretForm(request.POST) | 4543 form = ClientIDAndSecretForm(request.POST) |
| 4540 if form.is_valid(): | 4544 if form.is_valid(): |
| 4541 client_id = form.cleaned_data['client_id'] | 4545 client_id = form.cleaned_data['client_id'] |
| 4542 client_secret = form.cleaned_data['client_secret'] | 4546 client_secret = form.cleaned_data['client_secret'] |
| 4543 additional_client_ids = form.cleaned_data['additional_client_ids'] | 4547 additional_client_ids = form.cleaned_data['additional_client_ids'] |
| 4548 whitelisted_emails = form.cleaned_data['whitelisted_emails'] |
| 4544 logging.info('Adding client_id: %s' % client_id) | 4549 logging.info('Adding client_id: %s' % client_id) |
| 4545 auth_utils.SecretKey.set_config(client_id, client_secret, | 4550 auth_utils.SecretKey.set_config(client_id, client_secret, |
| 4546 additional_client_ids) | 4551 additional_client_ids, |
| 4552 whitelisted_emails) |
| 4547 else: | 4553 else: |
| 4548 logging.info('Form is invalid') | 4554 logging.info('Form is invalid') |
| 4549 return HttpResponseRedirect(reverse(set_client_id_and_secret)) | 4555 return HttpResponseRedirect(reverse(set_client_id_and_secret)) |
| 4550 else: | 4556 else: |
| 4551 client_id, client_secret, additional_client_ids = \ | 4557 client_id, client_secret, additional_client_ids, whitelisted_emails = \ |
| 4552 auth_utils.SecretKey.get_config() | 4558 auth_utils.SecretKey.get_config() |
| 4553 form = ClientIDAndSecretForm(initial={ | 4559 form = ClientIDAndSecretForm(initial={ |
| 4554 'client_id': client_id, | 4560 'client_id': client_id, |
| 4555 'client_secret': client_secret, | 4561 'client_secret': client_secret, |
| 4556 'additional_client_ids': additional_client_ids}) | 4562 'additional_client_ids': additional_client_ids, |
| 4563 'whitelisted_emails': whitelisted_emails}) |
| 4557 return respond(request, 'set_client_id_and_secret.html', {'form': form}) | 4564 return respond(request, 'set_client_id_and_secret.html', {'form': form}) |
| 4558 | 4565 |
| 4559 | 4566 |
| 4560 ### Statistics. | 4567 ### Statistics. |
| 4561 | 4568 |
| 4562 | 4569 |
| 4563 DATE_FORMAT = '%Y-%m-%d' | 4570 DATE_FORMAT = '%Y-%m-%d' |
| 4564 | 4571 |
| 4565 | 4572 |
| 4566 def update_stats(request): | 4573 def update_stats(request): |
| (...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5560 return HttpResponseNotFound() | 5567 return HttpResponseNotFound() |
| 5561 tops = [] | 5568 tops = [] |
| 5562 shame = [] | 5569 shame = [] |
| 5563 for i in data: | 5570 for i in data: |
| 5564 if i.score == models.AccountStatsBase.NULL_SCORE: | 5571 if i.score == models.AccountStatsBase.NULL_SCORE: |
| 5565 shame.append(i) | 5572 shame.append(i) |
| 5566 else: | 5573 else: |
| 5567 tops.append(i) | 5574 tops.append(i) |
| 5568 return respond( | 5575 return respond( |
| 5569 request, 'leaderboard.html', {'tops': tops, 'shame': shame, 'when': when}) | 5576 request, 'leaderboard.html', {'tops': tops, 'shame': shame, 'when': when}) |
| OLD | NEW |