Skip to content

Commit

Permalink
Merge pull request #82 from mkumar-02/15.0-1.1.0
Browse files Browse the repository at this point in the history
G2P-192 Added error handling in ID type.
  • Loading branch information
shibu-narayanan authored Aug 3, 2023
2 parents 62da541 + a5a1e3e commit 58d7ef3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions g2p_registry_rest_api/models/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ class GroupInfoIn(RegistrantInfoIn):
@validator("kind")
def validate_kind_no_spaces(cls, value): # noqa: B902
# Using lstrip() to remove leading spaces from the value
value = value.lstrip() if value else value
new_val = value.lstrip() if value else value

# Checking if the length of the cleaned value is less than 1
if len(value) < 1:
if value and len(new_val) < 1:
raise G2PApiValidationError(
error_message=G2PErrorCodes.G2P_REQ_001.get_error_message(),
error_code=G2PErrorCodes.G2P_REQ_001.get_error_code(),
Expand Down
4 changes: 2 additions & 2 deletions g2p_registry_rest_api/models/registrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ class RegistrantIDIn(NaiveOrmModel):
@validator("id_type")
def validate_id_type_no_spaces(cls, value): # noqa: B902
# Using lstrip() to remove leading spaces from the value
value = value.lstrip() if value else value
new_val = value.lstrip() if value else value

# Checking if the length of the cleaned value is less than 1
if len(value) < 1:
if value and len(new_val) < 1:
raise G2PApiValidationError(
error_message=G2PErrorCodes.G2P_REQ_005.get_error_message(),
error_code=G2PErrorCodes.G2P_REQ_005.get_error_code(),
Expand Down
14 changes: 14 additions & 0 deletions g2p_registry_rest_api/services/process_individual_mixin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from odoo.addons.component.core import AbstractComponent

from ..exceptions.base_exception import G2PApiValidationError
from ..exceptions.error_codes import G2PErrorCodes


class ProcessIndividualMixin(AbstractComponent):
_name = "process_individual.rest.mixin"
Expand Down Expand Up @@ -60,6 +63,17 @@ def _process_ids(self, ids_info):
},
)
)

elif rec.id_type:
raise G2PApiValidationError(
error_message=G2PErrorCodes.G2P_REQ_005.get_error_message(),
error_code=G2PErrorCodes.G2P_REQ_005.get_error_code(),
error_description=(
("ID type - %s is not present in the database.")
% rec.id_type
),
)

return ids

def _process_phones(self, ids_info):
Expand Down

0 comments on commit 58d7ef3

Please sign in to comment.