Skip to content

Commit

Permalink
Updated mentorship_relation.py functions to use enum class
Browse files Browse the repository at this point in the history
  • Loading branch information
ciheanyi committed Apr 14, 2022
1 parent 8977489 commit 4c95a05
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/api/dao/mentorship_relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ def list_mentorship_relations(user_id=None, state=None):
message: A message corresponding to the completed action; success if all relationships of a given user are listed, failure if otherwise.
"""
# To check if the entered 'state' is valid.
valid_states = ["PENDING", "ACCEPTED", "REJECTED", "CANCELLED", "COMPLETED"]

def isValidState(rel_state):
if rel_state in valid_states:
return True
return False
try:
MentorshipRelationState[rel_state]
except KeyError:
return False
return True

user = UserModel.find_by_id(user_id)
all_relations = user.mentor_relations + user.mentee_relations
Expand Down

1 comment on commit 4c95a05

@ciheanyi
Copy link
Author

@ciheanyi ciheanyi commented on 4c95a05 Apr 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description

Code within isValidState function now uses an enum class when completing check for valid strings

Fixes # [1143]

Type of Change:

  • Code
  • Enhancement

How Has This Been Tested?

Checklist:

  • My PR follows the style guidelines of this project
  • I have performed a self-review of my own code or materials
  • I have commented my code or provided relevant documentation, particularly in hard-to-understand areas

Code/Quality Assurance Only

  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been published in downstream modules

Please sign in to comment.