mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-22 14:29:36 +02:00
Fix is_public mismatching
This commit is contained in:
parent
45cc925451
commit
eab2369352
2 changed files with 14 additions and 5 deletions
|
@ -204,8 +204,11 @@ class AdventureViewSet(viewsets.ModelViewSet):
|
||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
|
|
||||||
# if the adventure is trying to have is_public changed and its part of a collection return an error
|
# if the adventure is trying to have is_public changed and its part of a collection return an error
|
||||||
if 'is_public' in serializer.validated_data and instance.collection:
|
if new_collection is not None:
|
||||||
return Response({"error": "Cannot change is_public for adventures in a collection"}, status=400)
|
serializer.validated_data['is_public'] = new_collection.is_public
|
||||||
|
elif instance.collection:
|
||||||
|
serializer.validated_data['is_public'] = instance.collection.is_public
|
||||||
|
|
||||||
|
|
||||||
# Retrieve the collection from the validated data
|
# Retrieve the collection from the validated data
|
||||||
new_collection = serializer.validated_data.get('collection')
|
new_collection = serializer.validated_data.get('collection')
|
||||||
|
@ -243,8 +246,10 @@ class AdventureViewSet(viewsets.ModelViewSet):
|
||||||
print(new_collection)
|
print(new_collection)
|
||||||
|
|
||||||
# if the adventure is trying to have is_public changed and its part of a collection return an error
|
# if the adventure is trying to have is_public changed and its part of a collection return an error
|
||||||
if 'is_public' in serializer.validated_data and instance.collection:
|
if new_collection is not None:
|
||||||
return Response({"error": "Cannot change is_public for adventures in a collection"}, status=400)
|
serializer.validated_data['is_public'] = new_collection.is_public
|
||||||
|
elif instance.collection:
|
||||||
|
serializer.validated_data['is_public'] = instance.collection.is_public
|
||||||
|
|
||||||
if new_collection is not None and new_collection!=instance.collection:
|
if new_collection is not None and new_collection!=instance.collection:
|
||||||
# Check if the user is the owner of the new collection
|
# Check if the user is the owner of the new collection
|
||||||
|
|
|
@ -25,7 +25,11 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h1 class="text-center font-bold text-4xl mb-4">Country List</h1>
|
<h1 class="text-center font-bold text-4xl">Country List</h1>
|
||||||
|
<!-- result count -->
|
||||||
|
<p class="text-center mb-4">
|
||||||
|
{filteredCountries.length} countries found
|
||||||
|
</p>
|
||||||
|
|
||||||
<div class="flex items-center justify-center mb-4">
|
<div class="flex items-center justify-center mb-4">
|
||||||
<input
|
<input
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue