profileview

This commit is contained in:
Torma Kristóf 2020-11-28 05:43:54 +01:00
parent cb0c866816
commit 46d4119aec
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
3 changed files with 12 additions and 3 deletions

View File

@ -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))
uploader = db.relationship("User", backref=db.backref("uploads", lazy=True))

View File

@ -3,7 +3,7 @@
{% block content %}
{% if current_user.is_authenticated %}
<div>
<h1>Welcome {{ user.username }}</h1>
<h1>Welcome {{ current_user.username }}</h1>
<a href="{{ url_for('UploadView:index') }}" class="btn btn-primary">Upload</a>
</div>
<br>

View File

@ -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)