From: Radek Czajka Date: Mon, 9 Nov 2026 23:10:49 +0000 (+0100) Subject: For upgrades X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/b09ddc60e118508d96906f26ecb0e1709ca89f1b For upgrades --- diff --git a/src/api/migrations/0004_bookuserdata_last_changed.py b/src/api/migrations/0004_bookuserdata_last_changed.py index 1e6f04715..fe6f9400d 100644 --- a/src/api/migrations/0004_bookuserdata_last_changed.py +++ b/src/api/migrations/0004_bookuserdata_last_changed.py @@ -3,7 +3,6 @@ # import datetime from django.db import migrations, models -from django.utils.timezone import utc class Migration(migrations.Migration): @@ -16,7 +15,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='bookuserdata', name='last_changed', - field=models.DateTimeField(default=datetime.datetime(2018, 11, 28, 14, 41, 2, 673054, tzinfo=utc), auto_now=True), + field=models.DateTimeField(default=datetime.datetime(2018, 11, 28, 14, 41, 2, 673054, tzinfo=datetime.timezone.utc), auto_now=True), preserve_default=False, ), ] diff --git a/src/bookmarks/models.py b/src/bookmarks/models.py index ca53cd6c3..ef24e83dc 100644 --- a/src/bookmarks/models.py +++ b/src/bookmarks/models.py @@ -29,18 +29,14 @@ class Bookmark(Syncable, models.Model): return str(self.uuid) def save(self, *args, **kwargs): - # TODO: placeholder. - try: - audio_l = self.book.get_audio_length() - except: - audio_l = 60 - - if self.anchor: - self.mode = 'text' - self.audio_timestamp = self.book.sync_elid(self.anchor) - if self.audio_timestamp: - self.mode = 'audio' - self.anchor = self.book.sync_ts(self.audio_timestamp) or '' + audio_l = self.book.get_audio_length() + if audio_l: + if self.anchor and self.audio_timestamp is None: + self.mode = 'text' + self.audio_timestamp = self.book.sync_elid(self.anchor) + elif not self.anchor and self.audio_timestamp is not None: + self.mode = 'audio' + self.anchor = self.book.sync_ts(self.audio_timestamp) or '' return super().save(*args, **kwargs) @classmethod diff --git a/src/club/models.py b/src/club/models.py index eb1439084..8c6c8db1f 100644 --- a/src/club/models.py +++ b/src/club/models.py @@ -1,7 +1,7 @@ # This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from decimal import Decimal import os import tempfile @@ -12,7 +12,7 @@ from django.core.mail import send_mail, EmailMessage from django.urls import reverse from django.db import models from django import template -from django.utils.timezone import now, utc +from django.utils.timezone import now from django.utils.translation import get_language from django_countries.fields import CountryField from catalogue.utils import get_random_hash @@ -314,7 +314,7 @@ class Membership(models.Model): Contact = apps.get_model('messaging', 'Contact') if self.manual: - Contact.update(email, Level.MANUAL_MEMBER, datetime.combine(self.updated_at, datetime.min.time(), utc)) + Contact.update(email, Level.MANUAL_MEMBER, datetime.combine(self.updated_at, datetime.min.time(), timezone.utc)) else: Contact.reset(email) @@ -497,7 +497,7 @@ class PayUOrder(payu_models.Order): booking_date__year=year ): payments.append({ - 'timestamp': datetime(pa.booking_date.year, pa.booking_date.month, pa.booking_date.day, tzinfo=utc), + 'timestamp': datetime(pa.booking_date.year, pa.booking_date.month, pa.booking_date.day, tzinfo=timezone.utc), 'amount': Decimal(str(pa.debit.amount) + '.00') }) diff --git a/src/funding/models.py b/src/funding/models.py index 81d439df8..36221f156 100644 --- a/src/funding/models.py +++ b/src/funding/models.py @@ -1,7 +1,7 @@ # This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # -from datetime import date, datetime +from datetime import date from urllib.parse import urlencode from django.conf import settings from django.contrib.sites.models import Site @@ -11,7 +11,7 @@ from django.dispatch import receiver from django.template.loader import render_to_string from django.urls import reverse from django.utils.html import mark_safe -from django.utils.timezone import utc +from django.utils.timezone import now from django.utils.translation import gettext_lazy as _, override from catalogue.models import Book from catalogue.utils import get_random_hash @@ -161,7 +161,7 @@ class Offer(models.Model): 'remaining': self.remaining(), 'current': self.current(), }) - self.notified_end = datetime.utcnow().replace(tzinfo=utc) + self.notified_end = now() self.save() def notify_near(self, force=False): @@ -179,7 +179,7 @@ class Offer(models.Model): 'sum': sum_, 'need': need, }) - self.notified_near = datetime.utcnow().replace(tzinfo=utc) + self.notified_near = now() self.save() def notify_published(self): diff --git a/src/lesmianator/models.py b/src/lesmianator/models.py index e32dd0467..f4c8e3b44 100644 --- a/src/lesmianator/models.py +++ b/src/lesmianator/models.py @@ -9,7 +9,7 @@ from random import randint from django.core.files.base import ContentFile from django.db import models -from django.utils.timezone import utc +from django.utils.timezone import now from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.fields import GenericForeignKey @@ -38,7 +38,7 @@ class Poem(models.Model): def visit(self): self.view_count += 1 - self.seen_at = datetime.utcnow().replace(tzinfo=utc) + self.seen_at = now() self.save() def __str__(self): diff --git a/src/social/api/views.py b/src/social/api/views.py index 8e09e81c5..a2d92ccf6 100644 --- a/src/social/api/views.py +++ b/src/social/api/views.py @@ -1,10 +1,10 @@ # This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # -from datetime import datetime +from datetime import datetime, timezone from django.db.models import Q from django.http import Http404 -from django.utils.timezone import now, utc +from django.utils.timezone import now from rest_framework.exceptions import MethodNotAllowed from rest_framework.generics import ListAPIView, ListCreateAPIView, RetrieveAPIView, RetrieveUpdateAPIView, RetrieveUpdateDestroyAPIView, get_object_or_404 from rest_framework.permissions import SAFE_METHODS, IsAuthenticated, IsAuthenticatedOrReadOnly @@ -355,7 +355,7 @@ class SyncView(ListAPIView): except: timestamp = 0 - timestamp = datetime.fromtimestamp(timestamp, tz=utc) + timestamp = datetime.fromtimestamp(timestamp, tz=timezone.utc) data = [] return self.get_queryset_for_ts(timestamp) diff --git a/src/social/models.py b/src/social/models.py index 45ee0f4a6..a8bec9cd5 100644 --- a/src/social/models.py +++ b/src/social/models.py @@ -11,7 +11,7 @@ from django.contrib.auth.models import User from django.core.exceptions import ValidationError from django.core.mail import send_mail from django.urls import reverse -from django.utils.timezone import now, utc +from django.utils.timezone import now from catalogue.models import Book from catalogue.utils import get_random_hash from wolnelektury.utils import cached_render, clear_cached_renders diff --git a/src/social/syncable.py b/src/social/syncable.py index 6447f344b..b86e2fd1a 100644 --- a/src/social/syncable.py +++ b/src/social/syncable.py @@ -1,5 +1,5 @@ -from datetime import datetime -from django.utils.timezone import now, utc +from datetime import datetime, timezone +from django.utils.timezone import now class Syncable: @@ -9,7 +9,7 @@ class Syncable: if ts is None: ts = now() else: - ts = datetime.fromtimestamp(ts, tz=utc) + ts = datetime.fromtimestamp(ts, tz=timezone.utc) if instance is not None: if ts and ts < instance.reported_timestamp: diff --git a/src/wolnelektury/settings/locale.py b/src/wolnelektury/settings/locale.py index 65b8200ea..baeb4e649 100644 --- a/src/wolnelektury/settings/locale.py +++ b/src/wolnelektury/settings/locale.py @@ -7,7 +7,6 @@ from .paths import PROJECT_DIR # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True -USE_L10N = True LOCALE_PATHS = [ path.join(PROJECT_DIR, 'locale')