Add question ownership and sharing
Questions now have a created_by field linking to the user who created them. Users only see questions they own or that have been shared with them. Includes share dialog, user search, bulk sharing, and export/import respects ownership. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""Routes for exporting and importing trivia questions"""
|
||||
import os
|
||||
import tempfile
|
||||
from flask import Blueprint, jsonify, Response, request
|
||||
from flask import Blueprint, jsonify, Response, request, g
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
from backend.auth.middleware import require_auth
|
||||
@@ -23,8 +23,8 @@ def export_data():
|
||||
ZIP file containing manifest.json and all media files
|
||||
"""
|
||||
try:
|
||||
# Generate export ZIP
|
||||
zip_bytes, zip_filename = export_questions_to_zip()
|
||||
# Generate export ZIP (only questions visible to current user)
|
||||
zip_bytes, zip_filename = export_questions_to_zip(user_id=g.current_user.id)
|
||||
|
||||
# Create response with ZIP file
|
||||
response = Response(
|
||||
@@ -82,8 +82,8 @@ def import_data():
|
||||
file_size = os.path.getsize(temp_path)
|
||||
print(f"Saved file size: {file_size} bytes")
|
||||
|
||||
# Import from ZIP
|
||||
result = import_questions_from_zip(temp_path)
|
||||
# Import from ZIP (set ownership to current user)
|
||||
result = import_questions_from_zip(temp_path, user_id=g.current_user.id)
|
||||
|
||||
return jsonify(result), 200
|
||||
|
||||
|
||||
Reference in New Issue
Block a user