Merge branch 'main' into avm99963-monorail
Merged commit cd4b3b336f1f14afa02990fdc2eec5d9467a827e
GitOrigin-RevId: e67bbf185d5538e1472bb42e0abb2a141f88bac1
diff --git a/framework/servlet_helpers.py b/framework/servlet_helpers.py
index 89fe587..fddec26 100644
--- a/framework/servlet_helpers.py
+++ b/framework/servlet_helpers.py
@@ -12,7 +12,7 @@
import calendar
import datetime
import logging
-import urllib
+from six.moves import urllib
import time
from framework import framework_constants
@@ -175,7 +175,7 @@
perm, mr.auth.effective_ids, project, permissions.GetRestrictions(art))
-def ComputeIssueEntryURL(mr, config):
+def ComputeIssueEntryURL(mr):
"""Compute the URL to use for the "New issue" subtab.
Args:
@@ -187,13 +187,12 @@
case. Otherewise it will be a fully qualified URL that includes some
query string parameters.
"""
- # TODO: remove the custom_issue_entry_url since its no longer
- if not config.custom_issue_entry_url:
+ isMember = framework_bizobj.UserIsInProject(mr.project, mr.auth.effective_ids)
+ if mr.project_name == 'chromium' and not isMember:
+ return '/p/chromium/issues/wizard'
+ else:
return '/p/%s/issues/entry' % (mr.project_name)
- return '/p/chromium/issues/wizard'
-
-
def IssueListURL(mr, config, query_string=None):
"""Make an issue list URL for non-members or members."""
url = '/p/%s%s' % (mr.project_name, urls.ISSUE_LIST)
@@ -201,7 +200,7 @@
url += '?' + query_string
elif framework_bizobj.UserIsInProject(mr.project, mr.auth.effective_ids):
if config and config.member_default_query:
- url += '?q=' + urllib.quote_plus(config.member_default_query)
+ url += '?q=' + urllib.parse.quote_plus(config.member_default_query)
return url
@@ -212,22 +211,25 @@
def SafeCreateLoginURL(mr, continue_url=None):
"""Make a login URL w/ a detailed continue URL, otherwise use a short one."""
- continue_url = continue_url or mr.current_page_url
+ current_page_url = mr.current_page_url_encoded
+ if settings.local_mode:
+ current_page_url = mr.current_page_url
+ continue_url = continue_url or current_page_url
try:
- url = users.create_login_url(continue_url)
+ # Check the URL length
+ generated_login_url = users.create_login_url(continue_url)
except users.RedirectTooLongError:
if mr.project_name:
- url = users.create_login_url('/p/%s' % mr.project_name)
+ continue_url = '/p/%s' % mr.project_name
else:
- url = users.create_login_url('/')
-
- # Give the user a choice of existing accounts in their session
- # or the option to add an account, even if they are currently
- # signed in to exactly one account.
- if mr.auth.user_id:
- # Notice: this makes assuptions about the output of users.create_login_url,
- # which can change at any time. See https://crbug.com/monorail/3352.
- url = url.replace('/ServiceLogin', '/AccountChooser', 1)
+ continue_url = '/'
+ if settings.local_mode:
+ return generated_login_url
+ # URL to allow user to choose an account when >1 account is logged in.
+ redirect_url = (
+ 'https://accounts.google.com/AccountChooser?continue='
+ 'https://uc.appengine.google.com/_ah/conflogin%3Fcontinue%3D{}')
+ url = redirect_url.format(continue_url)
return url