Python 3.11, relevant upgrades
[wolnelektury.git] / src / social / api / views.py
index 35af9a8..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.
 #
-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
@@ -21,7 +21,7 @@ from social.utils import likes
 from social import models
 import bookmarks.models
 from . import serializers
-from bookmarks.api.views import BookmarkSerializer
+from bookmarks.api.views import BookmarkSerializer, QuoteSerializer
 
 
 
@@ -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)
@@ -452,3 +452,11 @@ class BookmarkSyncView(SyncView):
             if data.get('location'):
                 ret = self.model.get_by_location(user, data['location'])
         return ret
+
+
+class QuoteSyncView(SyncView):
+    model = bookmarks.models.Quote
+    serializer_class = QuoteSerializer
+
+    sync_id_field = 'uuid'
+    sync_id_serializer_field = 'uuid'