mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-27 08:47:03 -05:00
feat: Add blog, media, and support apps, implement ride credits and image API, and remove toplist feature.
This commit is contained in:
@@ -8,6 +8,7 @@ preferences, privacy, notifications, and security.
|
||||
|
||||
from apps.api.v1.serializers.accounts import (
|
||||
CompleteUserSerializer,
|
||||
PublicUserSerializer,
|
||||
UserPreferencesSerializer,
|
||||
NotificationSettingsSerializer,
|
||||
PrivacySettingsSerializer,
|
||||
@@ -23,6 +24,7 @@ from apps.api.v1.serializers.accounts import (
|
||||
AvatarUploadSerializer,
|
||||
)
|
||||
from apps.accounts.services import UserDeletionService
|
||||
from apps.accounts.export_service import UserExportService
|
||||
from apps.accounts.models import (
|
||||
User,
|
||||
UserProfile,
|
||||
@@ -1583,6 +1585,57 @@ def upload_avatar(request):
|
||||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
|
||||
@extend_schema(
|
||||
operation_id="export_user_data",
|
||||
summary="Export all user data",
|
||||
description="Generate a JSON dump of all user data including profile, reviews, and lists.",
|
||||
responses={
|
||||
200: {
|
||||
"description": "User data export",
|
||||
"example": {
|
||||
"account": {"username": "user", "email": "user@example.com"},
|
||||
"profile": {"display_name": "User"},
|
||||
"content": {"park_reviews": [], "lists": []}
|
||||
}
|
||||
},
|
||||
401: {"description": "Authentication required"},
|
||||
},
|
||||
tags=["Self-Service Account Management"],
|
||||
)
|
||||
@api_view(["GET"])
|
||||
@permission_classes([IsAuthenticated])
|
||||
def export_user_data(request):
|
||||
"""Export all user data as JSON."""
|
||||
try:
|
||||
export_data = UserExportService.export_user_data(request.user)
|
||||
return Response(export_data, status=status.HTTP_200_OK)
|
||||
except Exception as e:
|
||||
logger.error(f"Error exporting data for user {request.user.id}: {e}", exc_info=True)
|
||||
return Response(
|
||||
{"error": "Failed to generate data export"},
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR
|
||||
)
|
||||
|
||||
|
||||
@extend_schema(
|
||||
operation_id="get_public_user_profile",
|
||||
summary="Get public user profile",
|
||||
description="Get the public profile of a user by username.",
|
||||
responses={
|
||||
200: PublicUserSerializer,
|
||||
404: {"description": "User not found"},
|
||||
},
|
||||
tags=["User Profile"],
|
||||
)
|
||||
@api_view(["GET"])
|
||||
@permission_classes([AllowAny])
|
||||
def get_public_user_profile(request, username):
|
||||
"""Get public user profile by username."""
|
||||
user = get_object_or_404(User, username=username)
|
||||
serializer = PublicUserSerializer(user)
|
||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||
|
||||
|
||||
# === MISSING FUNCTION IMPLEMENTATIONS ===
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user