Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 1 | # Copyright 2016 The Chromium Authors |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 4 | |
| 5 | """Redirect to /issues/entry or an external URL (like the wizard). |
| 6 | """ |
| 7 | from __future__ import print_function |
| 8 | from __future__ import division |
| 9 | from __future__ import absolute_import |
| 10 | |
| 11 | import logging |
| 12 | |
Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 13 | from framework import exceptions |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 14 | from framework import servlet |
| 15 | from framework import servlet_helpers |
| 16 | |
| 17 | |
| 18 | class IssueEntryAfterLogin(servlet.Servlet): |
| 19 | """Redirect after clicking "New issue" and logging in.""" |
| 20 | |
| 21 | # Note: This servlet does not use an HTML template. |
| 22 | |
| 23 | def GatherPageData(self, mr): |
| 24 | """Build up a dictionary of data values to use when rendering the page.""" |
| 25 | if not mr.auth.user_id: |
| 26 | self.abort(400, 'Only signed-in users should reach this URL.') |
| 27 | |
Adrià Vilanova Martínez | de94280 | 2022-07-15 14:06:55 +0200 | [diff] [blame] | 28 | entry_page_url = servlet_helpers.ComputeIssueEntryURL(mr) |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 29 | logging.info('Redirecting to %r', entry_page_url) |
Adrià Vilanova Martínez | de94280 | 2022-07-15 14:06:55 +0200 | [diff] [blame] | 30 | |
Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 31 | raise exceptions.RedirectException(entry_page_url) |
| 32 | |
| 33 | def GetIssueEntryAfterLogin(self, **kwargs): |
| 34 | return self.handler(**kwargs) |