1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-05 05:05:17 +02:00

Test patch for shared used collection adventures

This commit is contained in:
LukeVader 2025-07-09 10:36:45 +02:00 committed by GitHub
parent cadea118d3
commit 3215ae1744
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -122,16 +122,6 @@ class AdventureSerializer(CustomModelSerializer):
return [image for image in serializer.data if image is not None] return [image for image in serializer.data if image is not None]
def validate_collections(self, collections): def validate_collections(self, collections):
"""Validate that collections belong to the same user"""
if not collections:
return collections
user = self.context['request'].user
for collection in collections:
if collection.user_id != user:
raise serializers.ValidationError(
f"Collection '{collection.name}' does not belong to the current user."
)
return collections return collections
def validate_category(self, category_data): def validate_category(self, category_data):
@ -409,4 +399,4 @@ class CollectionSerializer(CustomModelSerializer):
for user in instance.shared_with.all(): for user in instance.shared_with.all():
shared_uuids.append(str(user.uuid)) shared_uuids.append(str(user.uuid))
representation['shared_with'] = shared_uuids representation['shared_with'] = shared_uuids
return representation return representation