For upgrades
authorRadek Czajka <radekczajka@wolnelektury.pl>
Mon, 9 Nov 2026 23:10:49 +0000 (00:10 +0100)
committerRadek Czajka <radekczajka@wolnelektury.pl>
Mon, 9 Nov 2026 23:10:49 +0000 (00:10 +0100)
src/api/migrations/0004_bookuserdata_last_changed.py
src/bookmarks/models.py
src/club/models.py
src/funding/models.py
src/lesmianator/models.py
src/social/api/views.py
src/social/models.py
src/social/syncable.py
src/wolnelektury/settings/locale.py

index 1e6f047..fe6f940 100644 (file)
@@ -3,7 +3,6 @@
 #
 import datetime
 from django.db import migrations, models
 #
 import datetime
 from django.db import migrations, models
-from django.utils.timezone import utc
 
 
 class Migration(migrations.Migration):
 
 
 class Migration(migrations.Migration):
@@ -16,7 +15,7 @@ class Migration(migrations.Migration):
         migrations.AddField(
             model_name='bookuserdata',
             name='last_changed',
         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,
         ),
     ]
             preserve_default=False,
         ),
     ]
index ca53cd6..ef24e83 100644 (file)
@@ -29,18 +29,14 @@ class Bookmark(Syncable, models.Model):
         return str(self.uuid)
 
     def save(self, *args, **kwargs):
         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
         return super().save(*args, **kwargs)
 
     @classmethod
index eb14390..8c6c8db 100644 (file)
@@ -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.
 #
 # 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
 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.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
 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 = 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)
 
         else:
             Contact.reset(email)
 
@@ -497,7 +497,7 @@ class PayUOrder(payu_models.Order):
                 booking_date__year=year
         ):
             payments.append({
                 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')
             })
 
                 'amount': Decimal(str(pa.debit.amount) + '.00')
             })
 
index 81d439d..36221f1 100644 (file)
@@ -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.
 #
 # 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
 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.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
 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(),
             })
                 '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):
         self.save()
 
     def notify_near(self, force=False):
@@ -179,7 +179,7 @@ class Offer(models.Model):
                 'sum': sum_,
                 'need': need,
             })
                 'sum': sum_,
                 'need': need,
             })
-        self.notified_near = datetime.utcnow().replace(tzinfo=utc)
+        self.notified_near = now()
         self.save()
 
     def notify_published(self):
         self.save()
 
     def notify_published(self):
index e32dd04..f4c8e3b 100644 (file)
@@ -9,7 +9,7 @@ from random import randint
 
 from django.core.files.base import ContentFile
 from django.db import models
 
 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
 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
 
     def visit(self):
         self.view_count += 1
-        self.seen_at = datetime.utcnow().replace(tzinfo=utc)
+        self.seen_at = now()
         self.save()
 
     def __str__(self):
         self.save()
 
     def __str__(self):
index 8e09e81..a2d92cc 100644 (file)
@@ -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.
 #
 # 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.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
 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
 
         except:
             timestamp = 0
 
-        timestamp = datetime.fromtimestamp(timestamp, tz=utc)
+        timestamp = datetime.fromtimestamp(timestamp, tz=timezone.utc)
         
         data = []
         return self.get_queryset_for_ts(timestamp)
         
         data = []
         return self.get_queryset_for_ts(timestamp)
index 45ee0f4..a8bec9c 100644 (file)
@@ -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.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
 from catalogue.models import Book
 from catalogue.utils import get_random_hash
 from wolnelektury.utils import cached_render, clear_cached_renders
index 6447f34..b86e2fd 100644 (file)
@@ -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:
 
 
 class Syncable:
@@ -9,7 +9,7 @@ class Syncable:
         if ts is None:
             ts = now()
         else:
         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:
 
         if instance is not None:
             if ts and ts < instance.reported_timestamp:
index 65b8200..baeb4e6 100644 (file)
@@ -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
 # 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')
 
 LOCALE_PATHS = [
     path.join(PROJECT_DIR, 'locale')