flask site buildout #2

Merged
finn merged 25 commits from mgtut1 into master 2024-08-05 08:41:03 +00:00
3 changed files with 15 additions and 13 deletions
Showing only changes of commit 626ababdc3 - Show all commits

View File

@ -1,13 +1,19 @@
from flask import render_template, flash, redirect, url_for, request
from flask_login import current_user, login_user, logout_user, login_required
from urllib.parse import urlsplit
from datetime import datetime, timezone
import sqlalchemy as sa
from app import app, db
from app.forms import LoginForm, RegistrationForm, EditProfileForm
import sqlalchemy as sa
from flask_login import current_user, login_user, logout_user, login_required
from app.models import User
@app.before_request
def before_request():
if current_user.is_authenticated:
current_user.last_seen = datetime.now(timezone.utc)
db.session.commit()
@app.route('/')
@app.route('/index')
@login_required
@ -27,12 +33,6 @@ def index():
#return posts;
return render_template('index.html', title='Home', posts=posts)
@app.before_request
def before_request():
if current_user.is_authenticated:
current_user.last_seen = datetime.now(timezone.utc)
db.session.commit()
@app.route('/login', methods=['GET', 'POST'])
def login():
if current_user.is_authenticated:
@ -92,6 +92,6 @@ def edit_profile():
return redirect(url_for('edit_profile'))
elif request.method == 'GET':
form.username.data = current_user.username
form.about_me.data = current_user.about_me()
form.about_me.data = current_user.about_me
return render_template('edit_profile.html', title='Edit Profile', form=form)

View File

@ -6,12 +6,14 @@
<td><img src="data:image/png;base64,{{ user.gen_avatar(write_png=False) }}"></td>
<td>
<h1>User: {{ user.username }}</h1>
<h1>CUdebug: {{ current_user }}</h1>
<h1>Udebug: {{ user }}</h1>
{% if user.about_me %}<p>{{ user.about_me }}</p>{% endif %}
{% if user.last_seen %}<p>Last activity:{{ user.last_seen }}</p>{% endif %}
</td>
</tr>
</table>
{% if user == current_user() %}
{% if user == current_user %}
<p><a href="{{ url_for('edit_profile') }}">Edit Profile</a></p>
{% endif %}
<hr>

View File

@ -1,8 +1,8 @@
"""empty message
Revision ID: 1a0e4f823e90
Revision ID: 4a2c3a72038e
Revises:
Create Date: 2024-08-03 04:56:53.822820
Create Date: 2024-08-03 05:02:15.935738
"""
from alembic import op
@ -10,7 +10,7 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '1a0e4f823e90'
revision = '4a2c3a72038e'
down_revision = None
branch_labels = None
depends_on = None