#
import datetime
from django.db import migrations, models
-from django.utils.timezone import utc
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,
),
]
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
# 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 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
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)
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')
})
# 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 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
'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):
'sum': sum_,
'need': need,
})
- self.notified_near = datetime.utcnow().replace(tzinfo=utc)
+ self.notified_near = now()
self.save()
def notify_published(self):
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
def visit(self):
self.view_count += 1
- self.seen_at = datetime.utcnow().replace(tzinfo=utc)
+ self.seen_at = now()
self.save()
def __str__(self):
# 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
except:
timestamp = 0
- timestamp = datetime.fromtimestamp(timestamp, tz=utc)
+ timestamp = datetime.fromtimestamp(timestamp, tz=timezone.utc)
data = []
return self.get_queryset_for_ts(timestamp)
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 datetime import datetime
-from django.utils.timezone import now, utc
+from datetime import datetime, timezone
+from django.utils.timezone import now
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:
# 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')