【百度云搜索,搜各种资料:http://www.81ad.cn】
Flask 构建微电影视频网站
已上线演示地址: http://movie.tbquan.cn
评论记录
修改 comments评论记录视图
@home.route('/comments/<int:page>/')
@user_login_require
def comments(page):
if not page:
page = 1
page_comments =Comment.query.filter_by(
user_id=int(session['login_user_id'])
).order_by(
Comment.add_time.desc()
).paginate(page=page, per_page=10)
return render_template('home/comments.html', page_comments=page_comments)
修改usermenu.html评论记录链接
<a id="m-3" href="{{ url_for('home.comments', page=1) }}" class="list-group-item">
<span class="glyphicon glyphicon-comment"></span> 评论记录
</a>
修改comments.html评论记录列表
<ul class="commentList">
{% for comment in page_comments.items %}
<li class="item cl">
<a href="user.html">
<i class="avatar size-L radius">
<img alt="50x50" src="{{ url_for('static', filename='user/' + comment.user.face) }}" class="img-circle" style="border:1px solid #abcdef; width: 50px">
</i>
</a>
<div class="comment-main">
<header class="comment-header">
<div class="comment-meta">
<a class="comment-author" href="{{ url_for('home.user') }}">{{ comment.user.name }}</a>
评论于
<time title="{{ comment.add_time }}" datetime="{{ comment.add_time }}">{{ comment.add_time }}</time>
</div>
</header>
<div class="comment-body">
<p>{{ comment.content }}!</p>
</div>
</div>
</li>
{% endfor %}
</ul>
{% import 'home/pagination.html' as pg %}
{{ pg.render_pagination(page_comments, 'home.comments') }}
BLOG_20181112_215626_37
会员登录日志
修改userlog会员登录日志视图
@home.route('/userlog/<int:page>/')
@user_login_require
def userlog(page=None):
"""会员登录日志"""
if not page:
page = 1
page_user_logs = UserLog.query.filter_by(
user_id=int(session['login_user_id'])
).order_by(
UserLog.add_time.desc()
).paginate(page=page, per_page=10)
return render_template('home/userlog.html', page_user_logs=page_user_logs)
修改usermenu.html登录日志链接
<a id="m-4" href="{{ url_for('home.userlog', page=1) }}" class="list-group-item">
<span class="glyphicon glyphicon-calendar"></span> 登录日志
</a>
增加pagination.html分页模板
<div class="col-md-12 text-center" style="margin-top:6px;">
<nav aria-label="Page navigation">
{% macro render_pagination(pagination, url_route) %}
<ul class="pagination">
<li>
<a href="{{ url_for(url_route, page=1) }}" aria-label="First">
<span aria-hidden="true">首页</span>
</a>
</li>
{% if pagination.has_prev %}
<li>
<a href="{{ url_for(url_route, page=pagination.prev_num) }}" aria-label="Previous">
<span aria-hidden="true">上一页</span>
</a>
</li>
{% endif %}
{%- for page in pagination.iter_pages() %}
{% if page %}
{% if page != pagination.page %}
<li><a href="{{ url_for(url_route, page=page) }}">{{ page }}</a></li>
{% else %}
<li><a style="background: #0d6aad; color: white">{{ page }}</a></li>
{% endif %}
{% endif %}
{%- endfor %}
{% if pagination.has_next %}
<li>
<a href="{{ url_for(url_route, page=pagination.next_num) }}" aria-label="Next">
<span aria-hidden="true">下一页</span>
</a>
</li>
{% endif %}
<li>
<a href="{{ url_for(url_route, page=pagination.pages) }}" aria-label="Last">
<span aria-hidden="true">尾页</span>
</a>
</li>
</ul>
{% endmacro %}
</nav>
</div>
修改userlog.html登录日志显示模板
<div class="panel-body">
<table class="table table-bordered">
<tr>
<td style="width:10%">编号</td>
<td style="width:30%">登录时间</td>
<td style="width:30%">登录IP</td>
<td style="width:30%">登录地址</td>
</tr>
{% for user_log in page_user_logs.items %}
<tr>
<td>{{ user_log.id }}</td>
<td>{{ user_log.add_time }}</td>
<td>{{ user_log.ip }}</td>
<td>xxx</td>
</tr>
{% endfor %}
</table>
{% import 'home/pagination.html' as pg %}
{{ pg.render_pagination(page_user_logs, 'home.userlog') }}
</div>
BLOG_20181112_215638_82
会员收藏列表
修改moviecollect收藏电影列表视图
@home.route('/moviecollect/<int:page>/')
@user_login_require
def moviecollect(page):
if not page:
page = 1
page_moviecollects = MovieCollect.query.filter_by(
user_id=int(session['login_user_id'])
).order_by(
MovieCollect.add_time.desc()
).paginate(page=page, per_page=10)
return render_template('home/moviecollect.html', page_moviecollects=page_moviecollects)
修改usermenu.html会员收藏链接
<a id="m-5" href="{{ url_for('home.moviecollect', page=1) }}" class="list-group-item">
<span class="glyphicon glyphicon-heart"></span> 收藏电影
</a>
修改moviecollect.html会员收藏列表展示
<div class="col-md-12">
{% for moviecollect in page_moviecollects.items %}
<div class="media">
<div class="media-left">
<a href="{{ url_for('home.play') }}">
<img class="media-object" src="{{ url_for('static', filename='media/' + moviecollect.movie.logo) }}" alt="{{ moviecollect.movie.title }}" style="width: 120px">
</a>
</div>
<div class="media-body">
<h4 class="media-heading">{{ moviecollect.movie.title }}<a href="{{ url_for('home.play') }}" class="label label-primary pull-right"><span class="glyphicon glyphicon-play"></span>播放影片</a></h4>
{{ moviecollect.movie.info }}
</div>
</div>
{% endfor %}
</div>
{% import 'home/pagination.html' as pg %}
{{ pg.render_pagination(page_moviecollects, 'home.moviecollect') }}
BLOG_20181112_215653_91
网友评论