Skip to content

Commit

Permalink
Move validation check up
Browse files Browse the repository at this point in the history
  • Loading branch information
LJBabbage committed Sep 16, 2024
1 parent 52902e0 commit 79c2151
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ras_party/views/respondent_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ def validate_respondent_claim():
business_id = request.args.get("business_id")
survey_id = request.args.get("survey_id")

if not business_id or not party_uuid or not survey_id:
raise BadRequest("party_uuid, business id and survey_id are required")
if not (is_valid_uuid4(party_uuid) and is_valid_uuid4(business_id) and is_valid_uuid4(survey_id)):
return make_response("Bad request, party_uuid, business or survey id not UUID", 400)

if respondent_controller.is_user_enrolled(party_uuid, business_id, survey_id):
return make_response("Valid", 200)
Expand All @@ -130,8 +130,8 @@ def validate_respondent_claim():
def get_respondents_by_business_and_survey_id(business_id: UUID, survey_id: UUID) -> Response:
"""Gets a list of Respondents enrolled in a survey for a specified business"""

if is_valid_uuid4(survey_id) and is_valid_uuid4(business_id):
respondents = respondent_controller.get_respondents_by_survey_and_business_id(survey_id, business_id)
return make_response(respondents, 200)
else:
if not (is_valid_uuid4(survey_id) and is_valid_uuid4(business_id)):
return make_response("Bad request, business or survey id not UUID", 400)

respondents = respondent_controller.get_respondents_by_survey_and_business_id(survey_id, business_id)
return make_response(respondents, 200)

0 comments on commit 79c2151

Please sign in to comment.