feat: Enhance Adventure and Collection Management

- Added support for multiple collections in AdventureSerializer, allowing adventures to be linked to multiple collections.
- Implemented validation to ensure collections belong to the current user during adventure creation and updates.
- Introduced a signal to update adventure publicity based on the public status of linked collections.
- Updated file permission checks to consider multiple collections when determining access rights.
- Modified AdventureImageViewSet and AttachmentViewSet to check access against collections instead of a single collection.
- Enhanced AdventureViewSet to support filtering and sorting adventures based on collections.
- Updated frontend components to manage collections more effectively, including linking and unlinking adventures from collections.
- Adjusted API endpoints and data structures to accommodate the new collections feature.
- Improved user experience with appropriate notifications for collection actions.
This commit is contained in:
Sean Morley
2025-06-12 15:54:01 -04:00
parent d9070e68bb
commit 3f9a6767bd
22 changed files with 686 additions and 289 deletions

View File

@@ -362,12 +362,21 @@
} else {
let adventure = event.detail;
// add the collection id to the adventure collections array
if (!adventure.collections) {
adventure.collections = [collection.id];
} else {
if (!adventure.collections.includes(collection.id)) {
adventure.collections.push(collection.id);
}
}
let res = await fetch(`/api/adventures/${adventure.id}/`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ collection: collection.id.toString() })
body: JSON.stringify({ collections: adventure.collections })
});
if (res.ok) {
@@ -550,6 +559,7 @@
on:close={() => {
isShowingLinkModal = false;
}}
collectionId={collection.id}
on:add={addAdventure}
/>
{/if}