Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
abilpraju-aot committed Sep 6, 2024
1 parent 5a4a3e1 commit 79caa38
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
7 changes: 5 additions & 2 deletions forms-flow-api/src/formsflow_api/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ class BusinessErrorCode(ErrorCodeMixin, Enum):
HTTPStatus.BAD_REQUEST,
)
INVALID_INPUT = "Invalid input parameter", HTTPStatus.BAD_REQUEST
INVALID_FORM_VALIDATION_INPUT = "At least one query parameter (title, name, path) must be provided.", HTTPStatus.BAD_REQUEST

INVALID_FORM_VALIDATION_INPUT = (
"At least one query parameter (title, name, path) must be provided.",
HTTPStatus.BAD_REQUEST,
)

def __new__(cls, message, status_code):
"""Constructor."""
obj = object.__new__(cls)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,10 @@ class ValidateFormName(Resource):
@profiletime
@API.response(200, "OK:- Successful request.")
@API.response(400, "BAD_REQUEST:- Invalid request.")
@API.response(401, "UNAUTHORIZED:- Authorization header not provided or an invalid token passed.")
@API.response(
401,
"UNAUTHORIZED:- Authorization header not provided or an invalid token passed.",
)
@API.response(403, "FORBIDDEN:- Authorization will not help.")
def get():
"""Handle GET requests for validating form names.
Expand Down
10 changes: 8 additions & 2 deletions forms-flow-api/src/formsflow_api/services/form_process_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,12 +528,18 @@ def validate_form_name_path_title(request):
formio_service = FormioService()
form_io_token = formio_service.get_formio_access_token()
# Call the external validation API
validation_response = formio_service.get_form_search(query_params, form_io_token)
validation_response = formio_service.get_form_search(
query_params, form_io_token
)

# Check if the validation response has any results
if validation_response:
# Check if the form ID matches
if form_id and len(validation_response) == 1 and validation_response[0].get('_id') == form_id:
if (
form_id
and len(validation_response) == 1
and validation_response[0].get("_id") == form_id
):
return {}
# If there are results but no matching ID, the form name is still considered invalid
raise BusinessException(BusinessErrorCode.FORM_EXISTS)
Expand Down

0 comments on commit 79caa38

Please sign in to comment.