mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-05 05:05:17 +02:00
feat: add LocationQuickStart and LocationVisits components for enhanced location selection and visit management
- Implemented LocationQuickStart.svelte for searching and selecting locations on a map with reverse geocoding. - Created LocationVisits.svelte to manage visit dates and notes for locations, including timezone handling and validation. - Updated types to remove location property from Attachment type. - Modified locations page to integrate NewLocationModal for creating and editing locations, syncing updates with adventures.
This commit is contained in:
parent
31eb7fb734
commit
707c99651f
13 changed files with 3224 additions and 185 deletions
|
@ -230,7 +230,7 @@ class LocationSerializer(CustomModelSerializer):
|
|||
return obj.is_visited_status()
|
||||
|
||||
def create(self, validated_data):
|
||||
visits_data = validated_data.pop('visits', None)
|
||||
visits_data = validated_data.pop('visits', [])
|
||||
category_data = validated_data.pop('category', None)
|
||||
collections_data = validated_data.pop('collections', [])
|
||||
|
||||
|
|
|
@ -262,24 +262,38 @@ class ContentImageViewSet(viewsets.ModelViewSet):
|
|||
}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
|
||||
def _create_standard_image(self, request, content_object, content_type, object_id):
|
||||
"""Handle standard image creation"""
|
||||
# Add content type and object ID to request data
|
||||
request_data = request.data.copy()
|
||||
request_data['content_type'] = content_type.id
|
||||
request_data['object_id'] = object_id
|
||||
"""Handle standard image creation without deepcopy issues"""
|
||||
|
||||
# Create serializer with modified data
|
||||
# Get uploaded image file safely
|
||||
image_file = request.FILES.get('image')
|
||||
if not image_file:
|
||||
return Response({"error": "No image uploaded"}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
# Build a clean dict for serializer input
|
||||
request_data = {
|
||||
'content_type': content_type.id,
|
||||
'object_id': object_id,
|
||||
}
|
||||
|
||||
# Optionally add other fields (e.g., caption, alt text) from request.data
|
||||
for key in ['caption', 'alt_text', 'description']: # update as needed
|
||||
if key in request.data:
|
||||
request_data[key] = request.data[key]
|
||||
|
||||
# Create and validate serializer
|
||||
serializer = self.get_serializer(data=request_data)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
|
||||
# Save the image
|
||||
|
||||
# Save with image passed explicitly
|
||||
serializer.save(
|
||||
user=content_object.user if hasattr(content_object, 'user') else request.user,
|
||||
user=getattr(content_object, 'user', request.user),
|
||||
content_type=content_type,
|
||||
object_id=object_id
|
||||
object_id=object_id,
|
||||
image=image_file
|
||||
)
|
||||
|
||||
|
||||
return Response(serializer.data, status=status.HTTP_201_CREATED)
|
||||
|
||||
|
||||
def perform_create(self, serializer):
|
||||
# The content_type and object_id are already set in the create method
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue