mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-05 13:15:18 +02:00
Test patch for shared used collection adventures
This commit is contained in:
parent
cadea118d3
commit
3215ae1744
1 changed files with 1 additions and 11 deletions
|
@ -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):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue