Skip to content

Commit

Permalink
Improve the Django app example to be more robust (#523)
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch authored Nov 15, 2021
1 parent 1b5f4a1 commit 068749a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions examples/django/oauth_app/slack_datastores.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ def save(self, installation: Installation):
i = installation.to_dict()
if is_naive(i["installed_at"]):
i["installed_at"] = make_aware(i["installed_at"])
if "bot_token_expires_at" in i and is_naive(i["bot_token_expires_at"]):
if i.get("bot_token_expires_at") is not None and is_naive(
i["bot_token_expires_at"]
):
i["bot_token_expires_at"] = make_aware(i["bot_token_expires_at"])
if "user_token_expires_at" in i and is_naive(i["user_token_expires_at"]):
if i.get("user_token_expires_at") is not None and is_naive(
i["user_token_expires_at"]
):
i["user_token_expires_at"] = make_aware(i["user_token_expires_at"])
i["client_id"] = self.client_id
row_to_update = (
Expand All @@ -58,7 +62,7 @@ def save_bot(self, bot: Bot):
b = bot.to_dict()
if is_naive(b["installed_at"]):
b["installed_at"] = make_aware(b["installed_at"])
if "bot_token_expires_at" in b is not None and is_naive(
if b.get("bot_token_expires_at") is not None and is_naive(
b["bot_token_expires_at"]
):
b["bot_token_expires_at"] = make_aware(b["bot_token_expires_at"])
Expand Down

0 comments on commit 068749a

Please sign in to comment.