from flask import redirect, url_for, abort
from flask_login import login_required, current_user, logout_user
from app import app, db
from app.forms.account import UpdateAccountForm, RegistrationForm, DeleteAccountForm
from app.models.users import Member
from app.utils.render import render

@app.route('/user/<username>')
def user(username):
    user = Member.query.filter_by(name=username).first()
    if not user:
        abort(404)
    return render('user.html', user=user)

@app.route('/user/id/<int:user_id>')
def user_by_id(user_id):
    user = Member.query.filter_by(id=user_id).first()
    if not user:
    	abort(404)
    return redirect(url_for('user', username=user.name))
