Ejemplo n.º 1
0
def main_temp_2():
    uuid = request.args.get("uuid")
    # render comments by uuid
    # we don't need to login to see comments
    # how to get comments data? By api or by url?
    comments = Comment.show_message(uuid=uuid)
    return render_template("comment_info_temp.html", comments=comments)
Ejemplo n.º 2
0
def video(id=None, page=None):
    movie = Movie.query.join(Tag).filter(Tag.id == Movie.tag_id,Movie.id == int(id)).first_or_404()
    if page is None:
        page = 1
    page_data = Comment.query.join(Movie).join(User).filter(Movie.id == movie.id,User.id == Comment.user_id).\
        order_by(Comment.add_time.desc()).paginate(page=page, per_page=10)

    movie.play_num = movie.play_num + 1
    form = CommentForm()
    if form.validate_on_submit():
        data = form.data
        comment = Comment(
            content=data["content"],
            movie_id=movie.id,
            user_id=current_user.id
        )
        db.session.add(comment)
        db.session.commit()
        movie.comment_num = movie.comment_num + 1
        db.session.add(movie)
        db.session.commit()
        flash("添加评论成功!")
        return redirect(url_for('home.video', id=movie.id, page=1))
    db.session.add(movie)
    db.session.commit()
    return render_template("home/video.html", movie=movie, form=form, page_data=page_data)
Ejemplo n.º 3
0
def reviews(post_id=Post.id):
    comment_form = forms.CommentForm(request.form)
    if request.method == 'POST' and comment_form.validate():

        user_id = session['user_id']
        comment = Comment(user_id=user_id,
                          post_id=post_id,
                          text=comment_form.comment.data)

        db.session.add(comment)
        db.session.commit()

        success_message = 'Comentario agregado!'
        flash(success_message)

    num = post_id
    posts = db.session.query(Post).filter_by(id=num).first()
    comment = db.session.query(Comment).filter(Comment.post_id == num).all()
    comment_len = len(comment)

    return render_template('reviews.html',
                           post=posts,
                           form=comment_form,
                           comment_len=comment_len,
                           comments=comment,
                           date_format=date_format)
Ejemplo n.º 4
0
def scc_article(uuid):
    if request.args.get('edit') == 'true':
        return redirect(url_for("scc.article_editor", uuid=uuid))
    if request.args.get("logout") == "true":
        logout_user()

    if request.method == "POST":
        db.session.add(
            Comment(uid=uuid,
                    rdr_name=request.form.get("nickname"),
                    rdr_mail=request.form.get("mail-address"),
                    rdr_message=request.form.get("comment-content"),
                    reply_to_id=request.form.get("reply_to_id")))
        db.session.commit()
        return redirect(url_for("scc.scc_article", uuid=uuid))
    article_by_uuid = Article.get_article_by_uuid(uuid=uuid)
    return render_template('ArticleTemplate.html',
                           article_by_uuid=article_by_uuid)
Ejemplo n.º 5
0
def cxw_article(uuid):
    article = Article.get_article_by_uuid(uuid=uuid)

    if request.args.get("edit") == "true":
        return redirect(url_for("cxw.cxw_article_editor", uuid=uuid))
    if request.args.get("logout") == "true":
        logout_user()
        return redirect(url_for("cxw.cxw_article", uuid=uuid))

    if request.method == "POST":
        db.session.add(
            Comment(uid=uuid,
                    rdr_name=request.form.get("nickname"),
                    rdr_mail=request.form.get("mail-address"),
                    rdr_message=request.form.get("comment-content"),
                    reply_to_id=request.form.get("reply_to_id")))
        db.session.commit()
        return redirect(url_for("cxw.cxw_article", uuid=uuid))
    return render_template("ArticleTemplateTheme_1.html", article=article)
Ejemplo n.º 6
0
def scc_root(page=1):
    recent_articles = Article.recent_articles(author='scc')
    recent_comments = Comment.recent_comments(author='scc')
    archive = Article.archive_statistic(author="scc")
    tags = Article.tag_statistic(author="scc")

    if request.args.get("article", ""):
        # redirect to article URL if get the ?article=uuid
        return redirect(
            url_for("scc.scc_article", uuid=request.args.get("article")))

    pagination = Article.pagination(page=int(request.args.get('page', page)),
                                    author='scc')
    latest_10 = Article.latest_article(page=int(request.args.get('page',
                                                                 page)),
                                       author='scc')
    return render_template('SccBlog.html',
                           latest_10=latest_10,
                           pagination=pagination,
                           recent_articles=recent_articles,
                           recent_comments=recent_comments,
                           archive=archive,
                           tags=tags)
Ejemplo n.º 7
0
 def delete(self, id):
     try:
         Comment.del_message(row_id=request.form.get("_id_"))
         return {"message": "success"}, 200
     except Exception as e:
         return {"message": "failed"}, 500
Ejemplo n.º 8
0
def main_temp_3():
    comments = [x.Comment for x in Comment.approved_message(usr=current_user.user)]
    return render_template("comments_info_temp.html", comments=comments)