Skip to content

Commit 32e1a64

Browse files
committed
Add profile tooltip and change profile viewing logic to be more restrictive
1 parent abeb18c commit 32e1a64

File tree

3 files changed

+62
-19
lines changed

3 files changed

+62
-19
lines changed

csm_web/frontend/src/components/UserProfile.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,19 @@ const UserProfile: React.FC = () => {
159159
return (
160160
<div className="user-profile-page">
161161
<div className="user-profile-main">
162+
{canEdit && (
163+
<Tooltip
164+
placement="bottom"
165+
source={<InfoIcon className="icon user-tooltip-icon" />}
166+
className="user-profile-tooltip"
167+
>
168+
<div>
169+
Edit your profile so others can get to know you. <br /> <br />
170+
Students: your profile is visible to mentors and coordinators. <br />
171+
Mentors: your profile is publicly viewable.
172+
</div>
173+
</Tooltip>
174+
)}
162175
{viewing ? (
163176
<>
164177
<div className="user-profile-viewing-header">
@@ -257,7 +270,11 @@ const UserProfile: React.FC = () => {
257270
<label htmlFor="preferredName" className="form-label">
258271
Preferred&nbsp;Name
259272
</label>
260-
<Tooltip placement="top" source={<InfoIcon className="icon" />} className="user-profile-tooltip">
273+
<Tooltip
274+
placement="top"
275+
source={<InfoIcon className="icon user-tooltip-icon" />}
276+
className="user-profile-preferred-name-tooltip"
277+
>
261278
<div>
262279
A blank name field will default to
263280
<br />

csm_web/frontend/src/css/profile.scss

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
}
88

99
.user-profile-main {
10+
position: relative;
1011
display: flex;
1112
flex-direction: column;
1213
gap: 0.5rem;
@@ -84,6 +85,27 @@
8485
width: 100%;
8586
}
8687

88+
.user-profile-tooltip {
89+
position: absolute;
90+
top: 1rem;
91+
right: 1rem;
92+
93+
display: inline-flex; // shrink to icon size
94+
align-items: center;
95+
justify-content: center;
96+
width: auto;
97+
height: auto;
98+
99+
.icon {
100+
width: 1.25rem; // or whatever size you like
101+
height: 1.25rem;
102+
}
103+
}
104+
105+
.user-tooltip-icon {
106+
color: $csm-neutral;
107+
}
108+
87109
.user-profile-input {
88110
display: flex;
89111
flex-direction: row;
@@ -154,7 +176,7 @@
154176
align-items: center;
155177
}
156178

157-
.user-profile-tooltip {
179+
.user-profile-preferred-name-tooltip {
158180
flex: 0;
159181
}
160182

csm_web/scheduler/views/user.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def user_editable(request_user, target_user):
128128
coordinator_courses = Coordinator.objects.filter(user=request_user).values_list(
129129
"course", flat=True
130130
)
131+
print(coordinator_courses)
131132
if Student.objects.filter(
132133
user=target_user, course__in=coordinator_courses
133134
).exists():
@@ -150,35 +151,38 @@ def has_permission(request_user, target_user):
150151

151152
# If the request_user can edit the target_user's profile, return True
152153
# This includes superusers, if the request_user is the target_user, or
153-
# if the request_user is a coordinator or a course the target_user is in
154+
# if the request_user is a coordinator of a course the target_user is in
154155
if user_editable(request_user, target_user):
155156
return True
156157

157158
# If the target user is a mentor, return True
158159
if Mentor.objects.filter(user=target_user).exists():
159160
return True
160161

162+
### For future use for students to contact other students in their section
161163
# If requestor is a student, get all the sections they are in
162164
# If the target user is a student in any of those sections, return True
163-
if Student.objects.filter(user=request_user).exists():
164-
if Student.objects.filter(user=target_user).exists():
165-
request_user_sections = Student.objects.filter(
166-
user=request_user
167-
).values_list("section", flat=True)
168-
target_user_sections = Student.objects.filter(user=target_user).values_list(
169-
"section", flat=True
170-
)
171-
if set(request_user_sections) & set(target_user_sections):
172-
return True
173-
174-
# If requestor is a mentor, get all the courses they mentor
175-
# If the target user is a student or mentor in any of those courses, return True
165+
# if Student.objects.filter(user=request_user).exists():
166+
# if Student.objects.filter(user=target_user).exists():
167+
# request_user_sections = Student.objects.filter(
168+
# user=request_user
169+
# ).values_list("section", flat=True)
170+
# target_user_sections = Student.objects.filter(user=target_user).values_list(
171+
# "section", flat=True
172+
# )
173+
# if set(request_user_sections) & set(target_user_sections):
174+
# return True
175+
176+
# If requestor is a mentor, get all the sections they mentor
177+
# If the target user is a student in any of those sections, return True
176178
if Mentor.objects.filter(user=request_user).exists():
177-
mentor_courses = Mentor.objects.filter(user=request_user).values_list(
178-
"course", flat=True
179+
mentor_sections = Mentor.objects.filter(user=request_user).values_list(
180+
"section", flat=True
179181
)
180182

181-
if Student.objects.filter(user=target_user, course__in=mentor_courses).exists():
183+
if Student.objects.filter(
184+
user=target_user, section__in=mentor_sections
185+
).exists():
182186
return True
183187

184188
return False

0 commit comments

Comments
 (0)