X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/c07a8fb779699c186417d5435e5b935ef340a3a5..e60aaa73e525b499e6703573539db1f3f1934668:/src/social/api/views.py diff --git a/src/social/api/views.py b/src/social/api/views.py index ea8b1287e..91d882da1 100644 --- a/src/social/api/views.py +++ b/src/social/api/views.py @@ -23,6 +23,20 @@ import bookmarks.models from bookmarks.api.views import BookmarkSerializer +class SettingsSerializer(serializers.ModelSerializer): + class Meta: + model = models.UserProfile + fields = ['notifications'] + + +class SettingsView(RetrieveUpdateAPIView): + permission_classes = [IsAuthenticated] + serializer_class = SettingsSerializer + + def get_object(self): + return models.UserProfile.get_for(self.request.user) + + @never_cache class LikeView(APIView): permission_classes = [IsAuthenticated] @@ -464,8 +478,9 @@ class BookmarkSyncView(SyncView): sync_id_field = 'uuid' sync_id_serializer_field = 'uuid' - def get_queryset_for_ts(self, timestamp): - return self.model.objects.filter( - user=self.request.user, - created_at__gt=timestamp - ).order_by('created_at') + def get_instance(self, user, data): + ret = super().get_instance(user, data) + if ret is None: + if data.get('location'): + ret = self.model.get_by_location(user, data['location']) + return ret