fnp
/
wolnelektury.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
9dc1452
)
user lists in sync
author
Radek Czajka
<rczajka@rczajka.pl>
Tue, 15 Jul 2025 14:02:44 +0000
(16:02 +0200)
committer
Radek Czajka
<rczajka@rczajka.pl>
Tue, 15 Jul 2025 14:02:44 +0000
(16:02 +0200)
src/social/api/views.py
patch
|
blob
|
history
diff --git
a/src/social/api/views.py
b/src/social/api/views.py
index
4f4937b
..
36c40e1
100644
(file)
--- a/
src/social/api/views.py
+++ b/
src/social/api/views.py
@@
-311,6
+311,7
@@
class SyncSerializer(serializers.Serializer):
return ret
return ret
+@never_cache
class SyncView(ListAPIView):
permission_classes = [IsAuthenticated]
serializer_class = SyncSerializer
class SyncView(ListAPIView):
permission_classes = [IsAuthenticated]
serializer_class = SyncSerializer
@@
-335,6
+336,20
@@
class SyncView(ListAPIView):
p, context={'request': self.request}
) if not p.deleted else None
})
p, context={'request': self.request}
) if not p.deleted else None
})
+
+ for p in models.UserList.objects.filter(
+ user=self.request.user,
+ updated_at__gt=timestamp).order_by('updated_at'):
+ data.append({
+ 'timestamp': p.updated_at.timestamp(),
+ 'type': 'user-list',
+ 'id': p.slug,
+ 'object': UserListSerializer(
+ p, context={'request': self.request}
+ ) if not p.deleted else None
+ })
+
+ data.sort(key=lambda x: x['timestamp'])
return data
def post(self, request):
return data
def post(self, request):
@@
-344,6
+359,9
@@
class SyncView(ListAPIView):
ser.is_valid(raise_exception=True)
d = ser.validated_data
if d['type'] == 'progress':
ser.is_valid(raise_exception=True)
d = ser.validated_data
if d['type'] == 'progress':
+ if d['object'] is not None:
+ objser = ProgressSerializer(data=d['object'])
+ objser.is_valid(raise_exception=True)
models.Progress.sync(
user=request.user,
slug=d['id'],
models.Progress.sync(
user=request.user,
slug=d['id'],