X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/55efada7f210cda246203bdef15bdd781ad26cfe..111a23185d6f47f692540fb145dc5604c47aee67:/src/social/api/views.py diff --git a/src/social/api/views.py b/src/social/api/views.py index 35af9a8ca..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 @@ -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'