# File: plugins/user/routes.py

from flask import Blueprint, render_template
from flask_login import login_required, current_user
from plugins.auth.models import User

bp = Blueprint(
    'user', __name__,
    url_prefix='/users',
    template_folder='templates'
)

@bp.route('/profile/')
@login_required
def profile_self():
    return render_template('user/profile.html', user=current_user, is_self=True)

@bp.route('/<int:user_id>/profile/')
@login_required
def profile(user_id):
    u = User.query.get_or_404(user_id)
    is_self = (u.id == current_user.id)
    return render_template('user/profile.html', user=u, is_self=is_self)
