Skip to content

Commit

Permalink
"Object of type str is not JSON serializable" when making contract (#38)
Browse files Browse the repository at this point in the history
* fixed serializable bug
  • Loading branch information
gcarvellas authored Sep 10, 2023
1 parent da6f7b8 commit 8f896b6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion controllers/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def post(self) -> FlaskResponseType:
helpers=data.get('helpers'),
num_additional_chairs=data['numAdditionalChairs'],
signer_email=current_cognito_jwt['email'], # TODO assert that emails are verified
signer_name=current_user,
signer_name=str(current_user),
artist_phone_number=data['artistPhoneNumber']
)
except NoApproverException:
Expand Down
2 changes: 1 addition & 1 deletion controllers/me.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MeController(BaseController):
@cognito_auth_required
@swag_from("swagger/me/get.yaml")
def get(self) -> FlaskResponseType:
result = MeManager().get_user(current_user, current_cognito_jwt)
result = MeManager().get_user(str(current_user), current_cognito_jwt)
return FlaskResponses().success(result)

@cognito_auth_required
Expand Down
4 changes: 2 additions & 2 deletions database/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def get_collection_async(cls) -> AsyncIOMotorCollection: # type: ignore[no-any-
return super().get_database_async()['users']

@classmethod
def add_user_contract(cls, uuid: str, contract_id: str) -> bool:
return cls.get_collection().updateOne(
def add_user_contract(cls, uuid: str, contract_id: str) -> pymongo.results.UpdateResult:
return cls.get_collection().update_one(
{"_id": uuid},
{"$addToSet": {"contracts": contract_id}}
)
Expand Down
2 changes: 2 additions & 0 deletions services/docusign/contract_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def generate_envelope(self) -> EnvelopeDefinition: # type: ignore[no-any-unimpo
text_envelope_args.append(Text(tab_label=key, value=getattr(self, key)))
elif type(getattr(self, key, None)) == int:
number_envelope_args.append(Number(tab_label=key, value=getattr(self, key)))
else:
raise Exception(f"Invalid key data. '{key}' with value '{getattr(self, key, None)}' with type '{type(getattr(self, key, None))}' can only be a string or int")

# Add helper badge information
if (self.helpers):
Expand Down

0 comments on commit 8f896b6

Please sign in to comment.