diff --git a/src/models/item.py b/src/models/item.py index b0a2612..ed67b62 100644 --- a/src/models/item.py +++ b/src/models/item.py @@ -19,4 +19,4 @@ class Item(db.Model): upload_date = db.Column(db.TIMESTAMP, nullable=False, server_default=func.now()) uploader_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="CASCADE"), nullable=False) - uploader = db.relationship("User", backref=db.backref("uploads", lazy=True)) \ No newline at end of file + uploader = db.relationship("User", backref=db.backref("uploads", lazy=True)) diff --git a/src/templates/profile.html b/src/templates/profile.html index bde69a9..9843da4 100644 --- a/src/templates/profile.html +++ b/src/templates/profile.html @@ -3,7 +3,7 @@ {% block content %} {% if current_user.is_authenticated %}
-

Welcome {{ user.username }}

+

Welcome {{ current_user.username }}

Upload

diff --git a/src/views/profileview.py b/src/views/profileview.py index 8494c4a..dcfafcf 100644 --- a/src/views/profileview.py +++ b/src/views/profileview.py @@ -2,6 +2,11 @@ from flask import render_template from flask_classful import FlaskView +from flask_security.decorators import login_required +from flask_security import current_user + +from models import Item + """ Profile VIEW """ @@ -14,5 +19,9 @@ __version__text__ = "1" class ProfileView(FlaskView): + @login_required def index(self): - return render_template('profile.html') + + useritems = Item.query.filter_by(uploader_id=current_user.id) + + return render_template('profile.html', images=useritems)