Skip to content

Commit

Permalink
API & Client - fix user detail display when user is not an admin
Browse files Browse the repository at this point in the history
  • Loading branch information
SamR1 committed Sep 29, 2024
1 parent e9ae49f commit f7587a6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions fittrackee/tests/users/test_users_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,7 @@ def test_it_returns_limited_user_infos_as_user(
'is_followed_by': user_2.is_followed_by(user_1),
'nb_workouts': user_2.workouts_count,
'picture': user_2.picture is not None,
'suspended_at': user_2.suspended_at,
'username': user_2.username,
}

Expand All @@ -1378,5 +1379,6 @@ def test_it_returns_limited_user_infos_as_unauthenticated_user(
'following': user_2.following.count(),
'nb_workouts': user_2.workouts_count,
'picture': user_2.picture is not None,
'suspended_at': user_2.suspended_at,
'username': user_2.username,
}
2 changes: 1 addition & 1 deletion fittrackee/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,10 @@ def serialize(
'following': self.following.count(),
'nb_workouts': self.workouts_count,
'picture': self.picture is not None,
'suspended_at': self.suspended_at,
'username': self.username,
}
if role in [UserRole.AUTH_USER, UserRole.ADMIN]:
serialized_user['suspended_at'] = self.suspended_at
serialized_user['is_active'] = self.is_active
if role == UserRole.ADMIN:
serialized_user['email'] = self.email
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<AlertMessage
message="user.ACCOUNT_SUSPENDED_AT"
:param="suspensionDate"
v-if="user.suspended_at !== null"
v-if="'suspended_at' in user && user.suspended_at !== null"
>
<template #additionalMessage v-if="displayMakeAppeal">
<router-link to="/profile/suspension" class="appeal-link">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</div>
<AlertMessage
message="user.THIS_USER_ACCOUNT_IS_INACTIVE"
v-if="!user.is_active"
v-if="authUser?.admin && !user.is_active"
/>
<ErrorMessage
:message="errorMessages"
Expand Down

0 comments on commit f7587a6

Please sign in to comment.