mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-19 04:49:37 +02:00
- 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.
17 lines
486 B
Python
17 lines
486 B
Python
from django.db import models
|
|
from django.db.models import Q
|
|
|
|
class AdventureManager(models.Manager):
|
|
def retrieve_adventures(self, user, include_owned=False, include_shared=False, include_public=False):
|
|
query = Q()
|
|
|
|
if include_owned:
|
|
query |= Q(user_id=user)
|
|
|
|
if include_shared:
|
|
query |= Q(collections__shared_with=user)
|
|
|
|
if include_public:
|
|
query |= Q(is_public=True)
|
|
|
|
return self.filter(query).distinct()
|