|
6 | 6 | session, |
7 | 7 | current_app, |
8 | 8 | g, |
| 9 | + request |
9 | 10 | ) |
10 | 11 | from authlib.integrations.flask_client import OAuth |
11 | 12 | from functools import wraps |
@@ -54,6 +55,7 @@ def login(): |
54 | 55 | @auth.route("/authorize") |
55 | 56 | def authorize(): |
56 | 57 | gamma = get_gamma() |
| 58 | + session['selected_extra_groups'] = request.args.getlist("extra_groups") |
57 | 59 | return gamma.authorize_redirect(url_for("auth.callback", _external=True)) |
58 | 60 |
|
59 | 61 |
|
@@ -84,21 +86,43 @@ def callback(): |
84 | 86 | # Filter groups to only include committees |
85 | 87 | active_groups = [ |
86 | 88 | { |
87 | | - "name": group.get("prettyName", {}), |
| 89 | + "prettyName": group.get("prettyName", {}), |
| 90 | + "name": group.get("name", {}), |
88 | 91 | "post": group.get("post", {}).get("enName"), |
89 | 92 | } |
90 | 93 | for group in groups_response |
91 | 94 | if group.get("superGroup", {}).get("type") != "alumni" |
92 | 95 | ] |
93 | 96 | except Exception as e: |
94 | 97 | print(f"Failed to get api information: {e}") |
95 | | - active_groups = "No data." |
| 98 | + active_groups = "N/A" |
| 99 | + |
| 100 | + extra_groups = [ |
| 101 | + { |
| 102 | + "name": "devit", |
| 103 | + "post": "Chairman", |
| 104 | + } |
| 105 | + if args == 'devit_ordf' |
| 106 | + else { |
| 107 | + "name": "devit", |
| 108 | + "post": "Treasurer", |
| 109 | + } |
| 110 | + if args == 'devit_kass' |
| 111 | + else { |
| 112 | + "name": args, |
| 113 | + "post": "Member", |
| 114 | + } |
| 115 | + for args in session['selected_extra_groups'] |
| 116 | + ] |
| 117 | + session.pop("selected_extra_groups", None) |
96 | 118 |
|
97 | 119 | essential_user_info = { |
98 | 120 | "name": user_info.get("name"), |
99 | 121 | "email": user_info.get("email"), |
100 | 122 | "cid": user_info.get("cid"), |
101 | | - "groups": active_groups, |
| 123 | + "groups": active_groups + extra_groups, |
| 124 | + "active_groups": active_groups, |
| 125 | + "extra_groups": extra_groups, |
102 | 126 | } |
103 | 127 |
|
104 | 128 | # Store user info in session |
|
0 commit comments