From 64e5f2c8e9e780040b2db3514896f7300ddc929e Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 9 Jul 2023 02:12:28 -0400 Subject: [PATCH] fix timezone convert error --- journal/views.py | 9 ++++++--- mastodon/api.py | 3 +-- users/models.py | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/journal/views.py b/journal/views.py index d99c19e7..a2d7b49a 100644 --- a/journal/views.py +++ b/journal/views.py @@ -175,7 +175,9 @@ def mark(request, item_uuid): mark_date = None if request.POST.get("mark_anotherday"): dt = parse_datetime(request.POST.get("mark_date", "") + " 20:00:00") - mark_date = timezone.get_current_timezone().localize(dt) if dt else None + mark_date = ( + dt.replace(tzinfo=timezone.get_current_timezone()) if dt else None + ) if mark_date and mark_date >= timezone.now(): mark_date = None TagManager.tag_item_by_user(item, request.user, tags, visibility) @@ -612,8 +614,9 @@ def review_edit(request, item_uuid, review_uuid=None): if form.is_valid(): mark_date = None if request.POST.get("mark_anotherday"): - mark_date = timezone.get_current_timezone().localize( - parse_datetime(request.POST.get("mark_date") + " 20:00:00") + dt = parse_datetime(request.POST.get("mark_date") + " 20:00:00") + mark_date = ( + dt.replace(tzinfo=timezone.get_current_timezone()) if dt else None ) body = form.instance.body if request.POST.get("leading_space"): diff --git a/mastodon/api.py b/mastodon/api.py index 89090d48..42622d17 100644 --- a/mastodon/api.py +++ b/mastodon/api.py @@ -9,8 +9,7 @@ from urllib.parse import quote from .models import MastodonApplication from mastodon.utils import rating_to_emoji import re - -logger = logging.getLogger(__name__) +from loguru import logger # See https://docs.joinmastodon.org/methods/accounts/ diff --git a/users/models.py b/users/models.py index 151762f0..3f752c34 100644 --- a/users/models.py +++ b/users/models.py @@ -366,7 +366,7 @@ class User(AbstractUser): self.mastodon_account = mastodon_account self.mastodon_locked = mastodon_account["locked"] if self.mastodon_username != mastodon_account["username"]: - logger.warn( + logger.warning( f"username changed from {self} to {mastodon_account['username']}" ) self.mastodon_username = mastodon_account["username"]