-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.py
94 lines (79 loc) · 2.75 KB
/
dashboard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from database.models import User
import streamlit
import ui.components.header
import ui.components.footer
import backend.user
import database.models
import ui.admin
import ui.student
def getDetails():
cols = streamlit.columns(
[
1,
1,
1,
]
)
cols[1].header("Onboarding")
githubUsername = cols[1].text_input("Github Username")
isGuide = cols[1].checkbox("Are you Faculty/Project Guide?")
if isGuide:
depertment = cols[1].multiselect(
"Select your department",
["Computer Science and Engineering", "Information Technology"],
)
else:
depertment = cols[1].selectbox(
"Select your department",
["Computer Science and Engineering", "Information Technology"],
)
batch = cols[1].selectbox(
"Select Year of Passing",
[2023, 2024, 2025],
)
submit = cols[1].button("Submit")
if submit:
if id == None:
cols[1].warning("Invalid Github username", icon="⚠️")
else:
user = backend.user.getUser(githubId=id)
if user == None:
streamlit.session_state.data["githubId"] = id
if isGuide:
if not backend.user.createGuide():
cols[1].warning("Something went wrong", icon="⚠️")
else:
streamlit.experimental_rerun()
else:
if not backend.user.createUser():
cols[1].warning("Something went wrong", icon="⚠️")
else:
streamlit.experimental_rerun()
else:
cols[1].warning("Github username already registered", icon="⚠️")
def dashboard():
ui.components.header.header()
if streamlit.session_state.admin:
ui.admin.adminDashboard()
else:
user = backend.user.getUser()
if user == None:
getDetails()
else:
if isinstance(user, database.models.Guide):
if not user.verified:
cols = streamlit.columns(3)
cols[1].info(
"Contact administrator to verify your faculty account - [email protected]",
icon="ℹ️",
)
refresh = cols[1].button("Refresh")
if refresh:
streamlit.experimental_rerun()
else:
streamlit.session_state.user = user
ui.guide.guideDashboard()
else:
streamlit.session_state.user = user
ui.student.studentDashboard()
ui.components.footer.footer()