From cc843878960f11b8d2d0f5a5152b14d4384ff902 Mon Sep 17 00:00:00 2001 From: Ken Tsang Date: Mon, 13 Feb 2017 14:00:41 +0000 Subject: [PATCH 1/3] Refactored in line with comments --- app/main/views/auth.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/main/views/auth.py b/app/main/views/auth.py index 8cbe269..6dead11 100644 --- a/app/main/views/auth.py +++ b/app/main/views/auth.py @@ -97,10 +97,10 @@ def match_idp_email(idp, email_address): def dept_from_idp_name(idp_name): - idp = [idp['name'] for idp in idp_profiles if idp_name == idp['idp_name']] - if idp: + dept = [profile['name'] + for profile in idp_profiles if idp_name == profile['idp_name']] + if dept: return ' or '.join(idp) - return None def idp_for_dept(dept): @@ -149,8 +149,8 @@ def authentication_request(): elif request.cookies.get('gateway_idp'): session['suggested_idp'] = request.cookies.get('gateway_idp') - department = dept_from_idp_name(session['suggested_idp']) - session['department_name'] = department + session['department_name'] = dept_from_idp_name( + session['suggested_idp']) return redirect(url_for('.confirm_dept')) return redirect(url_for('.request_email_address')) From ee2644b16d277f81ab1d3a9e2896ffeb2124ea1b Mon Sep 17 00:00:00 2001 From: Ken Tsang Date: Mon, 13 Feb 2017 15:10:31 +0000 Subject: [PATCH 2/3] Fixed bug in fn dept from idp name --- app/main/views/auth.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main/views/auth.py b/app/main/views/auth.py index 6dead11..a978072 100644 --- a/app/main/views/auth.py +++ b/app/main/views/auth.py @@ -100,7 +100,7 @@ def dept_from_idp_name(idp_name): dept = [profile['name'] for profile in idp_profiles if idp_name == profile['idp_name']] if dept: - return ' or '.join(idp) + return ' or '.join(dept) def idp_for_dept(dept): From 23082576d0013e6a01601b34d783db0769badbdf Mon Sep 17 00:00:00 2001 From: Ken Tsang Date: Fri, 3 Mar 2017 15:29:30 +0000 Subject: [PATCH 3/3] Refactored dept from idp name in line with Review --- app/main/views/auth.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/main/views/auth.py b/app/main/views/auth.py index a978072..7510a9f 100644 --- a/app/main/views/auth.py +++ b/app/main/views/auth.py @@ -97,10 +97,15 @@ def match_idp_email(idp, email_address): def dept_from_idp_name(idp_name): - dept = [profile['name'] - for profile in idp_profiles if idp_name == profile['idp_name']] - if dept: - return ' or '.join(dept) + depts = None + for profile in idp_profiles: + if idp_name == profile['idp_name']: + if depts is None: + depts = [] + depts.append(profile['name']) + + if depts: + return ' or '.join(depts) def idp_for_dept(dept):