Exemple #1
0
def team_page(teamid, page):
    count = Comment.count_comments_of_team(teamid)
    comments = Comment.list_team_comments(teamid, page)
    if not comments and page != 1:
        abort(404)
    return render_template("team/teampage.html",
                           team=Team.query.get(teamid),
                           form=CreateCommentForm(request.form),
                           users=User.list_by_score(team_id=teamid),
                           user=User.query.get(current_user.get_id()),
                           comments=comments,
                           count=count,
                           page=page)
Exemple #2
0
def team_send_comment(teamid):
    count = Comment.count_comments_of_team(teamid)
    form = CreateCommentForm(request.form)
    if not form.validate():
        return render_template("team/teampage.html",
                               team=Team.query.get(teamid),
                               form=form,
                               users=User.list_by_score(team_id=teamid),
                               user=User.query.get(current_user.get_id()),
                               comments=Comment.list_team_comments(teamid, 1),
                               count=count,
                               page=1)
    text = form.text.data
    comment = Comment(teamid, current_user.get_id(), text)
    db.session().add(comment)
    db.session().commit()
    return redirect(
        url_for("team_page",
                teamid=User.query.get(current_user.get_id()).team_id))