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:
@@ -122,3 +122,34 @@ def logout():
|
||||
def get_current_user():
|
||||
"""Get current user info (requires auth)"""
|
||||
return jsonify(g.current_user.to_dict()), 200
|
||||
|
||||
|
||||
@bp.route('/users/search')
|
||||
@require_auth
|
||||
def search_users():
|
||||
"""Search users by name, username, or email for sharing
|
||||
|
||||
Query parameters:
|
||||
- q: Search query (required, min 1 character)
|
||||
"""
|
||||
query = request.args.get('q', '').strip()
|
||||
if not query:
|
||||
return jsonify([]), 200
|
||||
|
||||
search_pattern = f'%{query}%'
|
||||
users = User.query.filter(
|
||||
User.id != g.current_user.id,
|
||||
User.is_active == True,
|
||||
db.or_(
|
||||
User.name.ilike(search_pattern),
|
||||
User.preferred_username.ilike(search_pattern),
|
||||
User.email.ilike(search_pattern)
|
||||
)
|
||||
).limit(10).all()
|
||||
|
||||
return jsonify([{
|
||||
'id': u.id,
|
||||
'name': u.name,
|
||||
'username': u.preferred_username,
|
||||
'email': u.email
|
||||
} for u in users]), 200
|
||||
|
||||
Reference in New Issue
Block a user