@ -1,7 +1,14 @@ | |||
from flask import render_template | |||
from . import main | |||
from ..models import User | |||
@main.route('/', methods=['GET', 'POST']) | |||
def index(): | |||
return render_template('index.html') | |||
@main.route('/user/<username>') | |||
def user(username): | |||
user = User.query.filter_by(username=username).first_or_404() | |||
return render_template('user.html', user=user) |
@ -0,0 +1,29 @@ | |||
{% extends "base.html" %} | |||
{% block title %}Flasky - {{ user.username }}{% endblock %} | |||
{% block page_content %} | |||
<div class="page-header"> | |||
<h1>{{ user.username }}</h1> | |||
{% if user.name or user.location %} | |||
<p> | |||
{% if user.name %} | |||
{{ user.name }}{% endif %} | |||
{% if user.location %}from | |||
<a href="https://maps.google.com/?q={{ user.location }}"> | |||
{{ user.location }}</a> | |||
{% endif %} | |||
</p> | |||
{% endif %} | |||
{% if user.is_administrator %} | |||
<p><a href="mailto:{{ user.email }}">{{ user.email }}</a></p> | |||
{% endif %} | |||
{% if user.about_me %} | |||
<p>{{ user.about_me }}</p> | |||
{% endif %} | |||
<p> | |||
Member since {{ moment(user.member_since).format('L') }}. | |||
Last seen {{ moment(user.last_seen).fromNow() }}. | |||
</p> | |||
</div> | |||
{% endblock %} |
@ -0,0 +1,36 @@ | |||
"""empty message | |||
Revision ID: 382a65f4b6c9 | |||
Revises: 417960a55273 | |||
Create Date: 2018-11-10 23:47:51.221299 | |||
""" | |||
from alembic import op | |||
import sqlalchemy as sa | |||
# revision identifiers, used by Alembic. | |||
revision = '382a65f4b6c9' | |||
down_revision = '417960a55273' | |||
branch_labels = None | |||
depends_on = None | |||
def upgrade(): | |||
# ### commands auto generated by Alembic - please adjust! ### | |||
op.add_column('users', sa.Column('about_me', sa.Text(), nullable=True)) | |||
op.add_column('users', sa.Column('last_seen', sa.DateTime(), nullable=True)) | |||
op.add_column('users', sa.Column('location', sa.String(length=64), nullable=True)) | |||
op.add_column('users', sa.Column('member_since', sa.DateTime(), nullable=True)) | |||
op.add_column('users', sa.Column('name', sa.String(length=64), nullable=True)) | |||
# ### end Alembic commands ### | |||
def downgrade(): | |||
# ### commands auto generated by Alembic - please adjust! ### | |||
op.drop_column('users', 'name') | |||
op.drop_column('users', 'member_since') | |||
op.drop_column('users', 'location') | |||
op.drop_column('users', 'last_seen') | |||
op.drop_column('users', 'about_me') | |||
# ### end Alembic commands ### |