Skip to content

Commit 4c95a05

Browse files
committed
Updated mentorship_relation.py functions to use enum class
1 parent 8977489 commit 4c95a05

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

app/api/dao/mentorship_relation.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,12 @@ def list_mentorship_relations(user_id=None, state=None):
136136
message: A message corresponding to the completed action; success if all relationships of a given user are listed, failure if otherwise.
137137
"""
138138
# To check if the entered 'state' is valid.
139-
valid_states = ["PENDING", "ACCEPTED", "REJECTED", "CANCELLED", "COMPLETED"]
140-
141139
def isValidState(rel_state):
142-
if rel_state in valid_states:
143-
return True
144-
return False
140+
try:
141+
MentorshipRelationState[rel_state]
142+
except KeyError:
143+
return False
144+
return True
145145

146146
user = UserModel.find_by_id(user_id)
147147
all_relations = user.mentor_relations + user.mentee_relations

0 commit comments

Comments
 (0)