profileview
This commit is contained in:
parent
cb0c866816
commit
46d4119aec
@ -19,4 +19,4 @@ class Item(db.Model):
|
|||||||
upload_date = db.Column(db.TIMESTAMP, nullable=False, server_default=func.now())
|
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_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))
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
{% if current_user.is_authenticated %}
|
{% if current_user.is_authenticated %}
|
||||||
<div>
|
<div>
|
||||||
<h1>Welcome {{ user.username }}</h1>
|
<h1>Welcome {{ current_user.username }}</h1>
|
||||||
<a href="{{ url_for('UploadView:index') }}" class="btn btn-primary">Upload</a>
|
<a href="{{ url_for('UploadView:index') }}" class="btn btn-primary">Upload</a>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
|
@ -2,6 +2,11 @@
|
|||||||
from flask import render_template
|
from flask import render_template
|
||||||
from flask_classful import FlaskView
|
from flask_classful import FlaskView
|
||||||
|
|
||||||
|
from flask_security.decorators import login_required
|
||||||
|
from flask_security import current_user
|
||||||
|
|
||||||
|
from models import Item
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Profile VIEW
|
Profile VIEW
|
||||||
"""
|
"""
|
||||||
@ -14,5 +19,9 @@ __version__text__ = "1"
|
|||||||
|
|
||||||
class ProfileView(FlaskView):
|
class ProfileView(FlaskView):
|
||||||
|
|
||||||
|
@login_required
|
||||||
def index(self):
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user