fix timezone convert error

This commit is contained in:
Your Name 2023-07-09 02:12:28 -04:00 committed by Henri Dickson
parent 8bbcf26fe2
commit 64e5f2c8e9
3 changed files with 8 additions and 6 deletions

View file

@ -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"):

View file

@ -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/

View file

@ -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"]