Skip to content

Commit

Permalink
fix: remove parsing warning status and overwritten default warning
Browse files Browse the repository at this point in the history
fix: remove parsing warning status and overwritten default warning st…
  • Loading branch information
elliottyu19 authored Jun 15, 2023
2 parents fcb4ce1 + 9a5f71a commit b8d1cdf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 1 addition & 2 deletions terra/api/api_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def _parse_api_body(
if "user" in body:
Auser = models.user.User.from_dict(body["user"])

if ("status" in body) and (body["status"] in STATUS.keys()):
if ("status" in body) and (body["status"] in STATUS.keys()) and (body["status"] != "warning"):
response = STATUS[body["status"]]().from_dict(body)

elif dtype in USER_DATATYPES:
Expand Down Expand Up @@ -352,7 +352,6 @@ class SentToWebhook(TerraParsedApiResponse):
"nutrition": models.v2.nutrition.Nutrition,
}


DTYPE_TO_RESPONSE = {
"widget_session": WidgetSession,
"auth_url": UserAuthUrl,
Expand Down
3 changes: 3 additions & 0 deletions terra/models/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ def from_dict(
(inner_item := getattr(data_model, k, *(("NOT_FOUND",) if safe else ()))) in [None, []]
or isinstance(inner_item, TerraDataModel)
or isinstance(v, list)
or (inner_item := getattr(data_model, k, *(("NOT_FOUND",) if safe else ()))) != v # Added this
# condition because the data model has a default status: warning and this condition allows it to
# get overwritten
):
if isinstance(inner_item, TerraDataModel):
v = inner_item.from_dict(v)
Expand Down

0 comments on commit b8d1cdf

Please sign in to comment.