1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-18 20:39:36 +02:00

fix(adventure): enhance collection ownership validation in AdventureSerializer (#723)

This commit is contained in:
Sean Morley 2025-07-09 23:03:48 -04:00 committed by GitHub
parent cadea118d3
commit 4e96e529f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -128,7 +128,7 @@ class AdventureSerializer(CustomModelSerializer):
user = self.context['request'].user user = self.context['request'].user
for collection in collections: for collection in collections:
if collection.user_id != user: if collection.user_id != user and not collection.shared_with.filter(id=user.id).exists():
raise serializers.ValidationError( raise serializers.ValidationError(
f"Collection '{collection.name}' does not belong to the current user." f"Collection '{collection.name}' does not belong to the current user."
) )