Skip to content

Commit f7fdf48

Browse files
committed
Added 'development' tools
1 parent 019eb47 commit f7fdf48

File tree

3 files changed

+71
-7
lines changed

3 files changed

+71
-7
lines changed

project/auth.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
session,
77
current_app,
88
g,
9+
request
910
)
1011
from authlib.integrations.flask_client import OAuth
1112
from functools import wraps
@@ -54,6 +55,7 @@ def login():
5455
@auth.route("/authorize")
5556
def authorize():
5657
gamma = get_gamma()
58+
session['selected_extra_groups'] = request.args.getlist("extra_groups")
5759
return gamma.authorize_redirect(url_for("auth.callback", _external=True))
5860

5961

@@ -84,21 +86,43 @@ def callback():
8486
# Filter groups to only include committees
8587
active_groups = [
8688
{
87-
"name": group.get("prettyName", {}),
89+
"prettyName": group.get("prettyName", {}),
90+
"name": group.get("name", {}),
8891
"post": group.get("post", {}).get("enName"),
8992
}
9093
for group in groups_response
9194
if group.get("superGroup", {}).get("type") != "alumni"
9295
]
9396
except Exception as e:
9497
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)
96118

97119
essential_user_info = {
98120
"name": user_info.get("name"),
99121
"email": user_info.get("email"),
100122
"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,
102126
}
103127

104128
# Store user info in session

project/templates/login.html

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,47 @@
44
<div class="column is-4 is-offset-4">
55
<h3 class="title">Login</h3>
66
<div class="box">
7-
<a href="{{ url_for('auth.authorize') }}" class="button is-block is-info is-large is-fullwidth">Login</a>
7+
<form action="{{ url_for('auth.authorize') }}" method="GET">
8+
<div class="field">
9+
<label class="label">Select Extra Access Groups:</label>
10+
<div class="control">
11+
<label class="checkbox">
12+
<input type="checkbox" name="extra_groups" value="digit">
13+
digIT
14+
</label>
15+
</div>
16+
<div class="control">
17+
<label class="checkbox">
18+
<input type="checkbox" name="extra_groups" value="styrit">
19+
styrIT
20+
</label>
21+
</div>
22+
<div class="control">
23+
<label class="checkbox">
24+
<input type="checkbox" name="extra_groups" value="motespresidit">
25+
MötespresidIT
26+
</label>
27+
</div>
28+
<div class="control">
29+
<label class="checkbox">
30+
<input type="checkbox" name="extra_groups" value="devit_ordf">
31+
DevIT Ordf
32+
</label>
33+
</div>
34+
<div class="control">
35+
<label class="checkbox">
36+
<input type="checkbox" name="extra_groups" value="devit_kass">
37+
DevIT Kassör
38+
</label>
39+
</div>
40+
</div>
41+
42+
<div class="field" style="margin-top: 1.5rem;">
43+
<div class="control">
44+
<button type="submit" class="button is-block is-info is-large is-fullwidth">Login</button>
45+
</div>
46+
</div>
47+
</form>
848
</div>
949
</div>
10-
{% endblock %}
50+
{% endblock %}

project/templates/profile.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ <h2>Profile Information</h2>
3232

3333
<!-- Active Groups -->
3434
{% if user.groups %}
35-
<p><strong>Active Groups:</strong>
35+
<p><strong>Groups:</strong>
3636
{% for group in user.groups %}
37-
{{ group.name }}{% if group.post %} ({{ group.post }}){% endif %}{% if not loop.last %}, {% endif %}
37+
{{ group.prettyName or group.name }}{% if group.post %} ({{ group.post }}){% endif %}{% if not loop.last %}, {% endif %}
3838
{% endfor %}
3939
</p>
4040
{% endif %}

0 commit comments

Comments
 (0)