Skip to content

Commit

Permalink
Fixed org schema mailing address issue and auth error logging. (#3065)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwei1018 authored Oct 3, 2024
2 parents 3e0ab60 + 181d257 commit 450c8ee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 45 deletions.
40 changes: 0 additions & 40 deletions auth-api/migrations/versions/2024_09_20_aa74003de9d8_.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ def upgrade():
sa.Column("modified_by_id", sa.Integer(), autoincrement=False, nullable=True),
sa.Column("version", sa.Integer(), autoincrement=False, nullable=False),
sa.Column("changed", sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(
["status_code"],
["affidavit_statuses.code"],
),
sa.PrimaryKeyConstraint("id", "version"),
sqlite_autoincrement=True,
)
Expand Down Expand Up @@ -70,26 +66,6 @@ def upgrade():
sa.Column("modified_by_id", sa.Integer(), autoincrement=False, nullable=True),
sa.Column("version", sa.Integer(), autoincrement=False, nullable=False),
sa.Column("changed", sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(
["business_size"], ["business_size_codes.code"], name="orgs_business_size_fkey", ondelete="SET NULL"
),
sa.ForeignKeyConstraint(
["business_type"], ["business_type_codes.code"], name="orgs_business_type_fkey", ondelete="SET NULL"
),
sa.ForeignKeyConstraint(
["status_code"],
["org_statuses.code"],
),
sa.ForeignKeyConstraint(
["suspension_reason_code"],
["suspension_reason_codes.code"],
name="orgs_suspension_reason_code_fkey",
ondelete="SET NULL",
),
sa.ForeignKeyConstraint(
["type_code"],
["org_types.code"],
),
sa.PrimaryKeyConstraint("id", "version"),
sqlite_autoincrement=True,
)
Expand Down Expand Up @@ -171,14 +147,6 @@ def upgrade():
sa.Column("modified_by_id", sa.Integer(), autoincrement=False, nullable=True),
sa.Column("version", sa.Integer(), autoincrement=False, nullable=False),
sa.Column("changed", sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(
["membership_type_code"],
["membership_types.code"],
),
sa.ForeignKeyConstraint(
["status"],
["membership_status_codes.id"],
),
sa.PrimaryKeyConstraint("id", "version"),
sqlite_autoincrement=True,
)
Expand Down Expand Up @@ -214,14 +182,6 @@ def upgrade():
sa.Column("modified_by_id", sa.Integer(), autoincrement=False, nullable=True),
sa.Column("version", sa.Integer(), autoincrement=False, nullable=False),
sa.Column("changed", sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(
["product_code"],
["product_codes.code"],
),
sa.ForeignKeyConstraint(
["status_code"],
["product_subscriptions_statuses.code"],
),
sa.PrimaryKeyConstraint("id", "version"),
sqlite_autoincrement=True,
)
Expand Down
2 changes: 1 addition & 1 deletion auth-api/src/auth_api/exceptions/exception_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, app=None):

def auth_handler(self, error): # pylint: disable=useless-option-value
"""Handle AuthError."""
logger.error(error.error)
logger.warning(error.error)
return error.error, error.status_code, RESPONSE_HEADERS

def db_handler(self, error): # pylint: disable=useless-option-value
Expand Down
8 changes: 4 additions & 4 deletions auth-api/src/auth_api/schemas/org.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Meta(BaseSchema.Meta): # pylint: disable=too-few-public-methods
suspension_reason_code = fields.String(data_key="suspension_reason_code")
business_size = fields.String(data_key="business_size")
business_type = fields.String(data_key="business_type")
contacts = fields.Pluck("ContactLinkSchema", "contact", many=True, data_key="mailing_address")
contacts = fields.Pluck("ContactLinkSchema", "contact", many=True, data_key="contacts")

@post_dump(pass_many=False)
def _include_dynamic_fields(self, data, many):
Expand All @@ -53,8 +53,8 @@ def _include_dynamic_fields(self, data, many):
# Adding a dynamic field businessName for making other application integrations easy.
data["businessName"] = data.get("name")
# Map the mailing address to the first from contact as there can be only one mailing address.

if (mailing_address := data.get("mailing_address", None)) is not None and mailing_address:
data["mailing_address"] = mailing_address[0]
if (mailing_address := data.get("contacts", None)) is not None and mailing_address:
if mailing_address[0] is not None and mailing_address[0].get("street", None) is not None:
data["mailing_address"] = mailing_address[0]

return data

0 comments on commit 450c8ee

Please sign in to comment.