예제 #1
0
def write_article(album_id):
    a = Album.query.get_or_404(album_id)
    if current_user != a.creator and not (current_user.is_administrator() or current_user.is_moderator()):
        abort(403)
    article_form = ArticleForm(prefix='article')
    if article_form.validate_on_submit():
        if current_user._get_current_object() is a.creator:
            p = Post(title=article_form.title.data.strip(), body_html=article_form.body_html.data.strip(), album=a,
                     author=current_user._get_current_object(), confirmed=True)
        else:
            p = Post(title=article_form.title.data.strip(), body_html=article_form.body_html.data.strip(), album=a,
                     author=current_user._get_current_object())
        db.session.add(p)
        current_user.send_message(user=a.creator, title=u'新文章需经过您的审核',
                                  content=u'<p>《%s》已由%s提交与专辑《%s》发表,</p>' % (p.title, current_user, a.title))
        return redirect(url_for('main.album', album_id=a.id))

    return render_template('auth/articles/write-article.html', articleForm=article_form)
예제 #2
0
def album_manage(album_id):
    a = Album.query.get_or_404(album_id)
    if current_user != a.creator and not (current_user.is_administrator() or current_user.is_moderator()):
        abort(403)
    adopt_album_form = AdoptAlbumForm(prefix='adopt_album')
    if adopt_album_form.validate_on_submit():
        a.confirmed = True
        current_user.send_message(user=a.creator, title=u'《%s》审核成功,已公开发表' % a.title,
                                  content=u'<p>尊敬的<strong>%s</strong></p><p><a href="%s">《%s》</a>经 %s 审核成功,已公开发表。</p>'
                                          % (a.creator.username, url_for('main.album', album_id=a.id), a.title, current_user.username))
        return redirect(request.args.get('next') or url_for('auth.albums'))

    reject_album_form = RejectAlbumForm(prefix='reject_album')
    if reject_album_form.validate_on_submit():
        a.confirmed = False
        current_user.send_message(user=a.creator, title=reject_album_form.title.data.strip(),
                                  content=u'<p>尊敬的<strong>%s</strong></p><p>很遗憾,您的<a href="%s">《%s》</a>经 %s 审核后,发表请求被驳回,原因如下:</p><p>%s</p>'
                                          % (a.creator.username, url_for('main.album', album_id=a.id), a.title, current_user.username, reject_album_form.content.data.strip()))
        return redirect(request.args.get('next') or url_for('auth.albums'))

    return render_template('auth/albums/album-manage.html', album=a, adoptAlbumForm=adopt_album_form,
                           rejectAlbumForm=reject_album_form)
예제 #3
0
def post_manage(post_id):
    p = Post.query.get_or_404(post_id)
    if current_user != p.author and not (current_user.is_administrator() or current_user.is_moderator()):
        abort(403)
    adopt_post_form = AdoptPostForm(prefix='adopt_post')
    if adopt_post_form.validate_on_submit():
        p.confirmed = True
        current_user.send_message(user=p.author, title=u'《%s》审核成功,已公开发表' % p.title,
                                  content=u'<p>尊敬的<strong>%s</strong></p><p><a href="%s">《%s》</a>经 %s 审核成功,已公开发表。</p>'
                                          % (p.author.username, url_for('main.post', post_id=p.id), p.title, current_user.username))
        return redirect(request.args.get('next') or url_for('auth.manage_articles', album_id=p.album.id))

    reject_post_form = RejectPostForm(prefix='reject_post')
    if reject_post_form.validate_on_submit():
        p.confirmed = False
        current_user.send_message(user=p.author, title=reject_post_form.title.data.strip(),
                                  content=u'<p>尊敬的<strong>%s</strong></p><p>很遗憾,您的<a href="%s">《%s》</a>经 %s 审核后,发表请求被驳回,原因如下:</p><p>%s</p>'
                                          % (p.author.username, url_for('main.post', post_id=p.id), p.title, current_user.username, reject_post_form.content.data.strip()))
        return redirect(request.args.get('next') or url_for('auth.manage_articles', album_id=p.album.id))

    return render_template('auth/articles/post-manage.html', post=p, adoptPostForm=adopt_post_form,
                           rejectPostForm=reject_post_form)