コード例 #1
0
ファイル: ajax.py プロジェクト: WiseFoolC/CUIT-ACM-Website
def get_related_submits():
    article_id = request.form.get('article_id')
    offset = request.form.get('offset')
    limit = request.form.get('limit')
    one = article_server.get_by_id(article_id)
    related_submits = article_server.related_submits(one, offset, limit)
    sum = article_server.related_submits_count(one)
    return jsonify(submits_list=[get_related_submits_item(submit) for submit in related_submits],
                   sum=sum, offset=int(offset), limit=len(related_submits))
コード例 #2
0
ファイル: index.py プロジェクト: Z2Y/CUIT-ACM-Website
def article():
    try:
        pid = request.args['p']
        one = article_server.get_by_id(pid)
        recent_articles = article_server.get_recent()
        return render_template('index/article.html',
                               title = one.title,
                               one = one,
                               recent_articles = recent_articles)
    except:
        return redirect(url_for('main.article_list'))
コード例 #3
0
def article():
    try:
        pid = request.args['p']
        one = article_server.get_by_id(pid)
        recent_articles = article_server.get_recent()
        return render_template('index/article.html',
                               title = one.title,
                               one = one,
                               recent_articles = recent_articles)
    except:
        return redirect(url_for('main.article_list'))
コード例 #4
0
def edit_article():
    try:
        one = article_server.get_by_id(request.args['p'])
        if one.user != current_user and (not current_user.is_admin and not current_user.is_coach):
            raise Exception(u"你没有权限修改该文章")
    except :
        return redirect(url_for('main.index'))
    solution_form = form.SolutionForm()
    if one:
        solution_form.sid.data = one.id
        solution_form.title.data = one.title
        solution_form.content.data = one.shortcut + '<-more->' + one.content if len(one.content) else one.shortcut
        tags = []
        for tag in one.tags:
            tags.append(tag.__repr__())
        solution_form.tags.data = tags
        solution_form.is_top.data = one.is_top
        solution_form.problem_oj_name.data = one.problem_oj_name
        solution_form.problem_pid.data = one.problem_pid
    if one.is_draft:
        my_button = [u"保存草稿", u"直接发布"]
    else :
        my_button = [u"保存草稿", u"提交更新"]
    return render_template('post_article.html', user=current_user, form=solution_form, my_button=my_button)