Skip to content

Commit 480d240

Browse files
committed
Add views for user and group details
1 parent 320abf0 commit 480d240

File tree

5 files changed

+109
-9
lines changed

5 files changed

+109
-9
lines changed

python-flask-directory-sync-example/app.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ def directory_users():
6161
return render_template("users.html", users=users)
6262

6363

64+
@app.route("/user")
65+
def directory_user():
66+
user_id = request.args.get("id")
67+
user = workos.client.directory_sync.get_user(
68+
user_id=user_id)
69+
print(user.model_dump())
70+
return render_template("user.html", user=user.model_dump(), id=user_id)
71+
72+
6473
@app.route("/groups")
6574
def directory_groups():
6675
directory_id = request.args.get("id")
@@ -70,6 +79,15 @@ def directory_groups():
7079
return render_template("groups.html", groups=groups)
7180

7281

82+
@app.route("/group")
83+
def directory_group():
84+
group_id = request.args.get("id")
85+
group = workos_client.directory_sync.get_group(
86+
group_id=group_id)
87+
88+
return render_template("group.html", group=group.model_dump(), id=group_id)
89+
90+
7391
@app.route("/webhooks", methods=["GET", "POST"])
7492
def webhooks():
7593
if request.data:
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<html>
2+
3+
<head>
4+
<link rel="stylesheet" href="../static/home.css">
5+
</head>
6+
7+
<body class="container_success">
8+
<div class="logged_in_nav">
9+
<div class="flex">
10+
<div>
11+
<img src="../static/images/workos-logo-with-text.png" alt="workos logo">
12+
</div>
13+
</div>
14+
<div>
15+
<a href="https://workos.com/docs" target="_blank"><button class='button nav-item'>Documentation</button></a>
16+
<a href="https://workos.com/docs/reference" target="_blank"><button class='button nav-item'>API
17+
Reference</button></a>
18+
<a href="https://workos.com/blog" target="_blank"><button
19+
class='button nav-item blog-nav-button'>Blog</button></a>
20+
<a href="https://workos.com/" target="_blank"><button class='button button-outline'>WorkOS</button></a>
21+
</div>
22+
</div>
23+
<div class='flex'>
24+
25+
<div class="logged_in_div_right">
26+
<div class="flex_column">
27+
<h2>Group Details</h2>
28+
<div>
29+
<pre id="noborder" class="prettyprint noborder">
30+
{{group|tojson_pretty}}
31+
</pre>
32+
</div>
33+
</div>
34+
</div>
35+
</div>
36+
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
37+
</body>
38+
39+
</html>

python-flask-directory-sync-example/templates/groups.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<link rel="stylesheet" href="../static/home.css">
55
</head>
66

7-
<body class="container_success">
7+
<body>
88
<div class="logged_in_nav">
99
<div class="flex">
1010
<div>
@@ -25,7 +25,7 @@
2525

2626
<div class="logged_in_div_right">
2727
<div class="flex_column">
28-
<div class="flex space-between width-507px">
28+
<div class="flex space-between width-40vw">
2929
<div>
3030
<h2>Groups Details</h2>
3131
</div>
@@ -36,15 +36,17 @@ <h2>Groups Details</h2>
3636
</div>
3737
{% if groups['data']|length > 0 %}
3838
<div>
39-
<table class="width-507px">
39+
<table class="width-40vw">
4040
<tr>
4141
<th>Name</th>
4242
<th>ID</th>
43+
<th>View Group</th>
4344
</tr>
4445
{% for group in groups['data'] %}
4546
<tr>
4647
<td class="ta-left">{{group['name']}}</td>
47-
<td class="ta-left"><code>{{group['id']}}</code></td>
48+
<td class="ta-left"><code>{{group['id']}}</code></td>
49+
<td><a class="button button-outline" href="/group?id={{group['id']}}">{{ lucide.icon('settings-2', stroke_width=1) }}</a></td>
4850
</tr>
4951
{% endfor %}
5052
</table>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<html>
2+
3+
<head>
4+
<link rel="stylesheet" href="../static/home.css">
5+
</head>
6+
7+
<body class="container_success">
8+
<div class="logged_in_nav">
9+
<div class="flex">
10+
<div>
11+
<img src="../static/images/workos-logo-with-text.png" alt="workos logo">
12+
</div>
13+
</div>
14+
<div>
15+
<a href="https://workos.com/docs" target="_blank"><button class='button nav-item'>Documentation</button></a>
16+
<a href="https://workos.com/docs/reference" target="_blank"><button class='button nav-item'>API
17+
Reference</button></a>
18+
<a href="https://workos.com/blog" target="_blank"><button
19+
class='button nav-item blog-nav-button'>Blog</button></a>
20+
<a href="https://workos.com/" target="_blank"><button class='button button-outline'>WorkOS</button></a>
21+
</div>
22+
</div>
23+
<div class='flex'>
24+
25+
<div class="logged_in_div_right">
26+
<div class="flex_column">
27+
<h2>User Details</h2>
28+
<div>
29+
<pre id="noborder" class="prettyprint noborder">
30+
{{user|tojson_pretty}}
31+
</pre>
32+
</div>
33+
</div>
34+
</div>
35+
</div>
36+
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
37+
</body>
38+
39+
</html>

python-flask-directory-sync-example/templates/users.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<link rel="stylesheet" href="../static/home.css">
55
</head>
66

7-
<body class="container_success">
7+
<body>
88
<div class="logged_in_nav">
99
<div class="flex">
1010
<div>
@@ -23,9 +23,9 @@
2323
<div class='flex'>
2424
<div class="logged_in_div_right">
2525
<div class="flex_column">
26-
<div class="flex space-between width-507px">
26+
<div class="flex space-between width-40vw">
2727
<div>
28-
<h2>User Details</h2>
28+
<h2>Directory Users</h2>
2929
</div>
3030
<div>
3131
<a href="javascript:history.back()"><button
@@ -34,15 +34,17 @@ <h2>User Details</h2>
3434
</div>
3535
{% if users['data']|length > 0 %}
3636
<div>
37-
<table class="width-507px">
37+
<table class="width-40vw">
3838
<tr>
3939
<th>Name</th>
4040
<th>Email</th>
41+
<th>View User</th>
4142
</tr>
4243
{% for user in users['data'] %}
4344
<tr>
4445
<td class="ta-left">{{user['first_name']}} {{user['last_name']}}</td>
45-
<td class="ta-left"><code>{{user['username']}}</code></td>
46+
<td class="ta-left"><code>{{user['username']}}</code></td>
47+
<td><a class="button button-outline" href="/user?id={{user['id']}}">{{ lucide.icon('settings-2', stroke_width=1) }}</a></td>
4648
</tr>
4749
{% endfor %}
4850
</table>

0 commit comments

Comments
 (0)