post.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:uchan 作者: Floens 项目源码 文件源码
def _check_post_settings(board: BoardModel, post_details):
    site_config = site_service.get_site_config()
    if not site_config.posting_enabled:
        raise BadRequestError(MESSAGE_POSTING_DISABLED)

    if post_details.has_file and not site_config.file_posting:
        raise BadRequestError(MESSAGE_FILE_POSTING_DISABLED)

    if board.config.posting_verification_required and not verification_service.is_verified(request):
        method = verification_service.get_method()
        if method.verification_in_request(request):
            try:
                method.verify_request(request)
                verification_service.set_verified(request)
            except ArgumentError as e:
                raise BadRequestError(e)
        else:
            message = 'Please verify here first before posting.'

            if request.is_xhr:
                xhr_response = {
                    'error': True,
                    'message': page_formatting('[{}](_/verify/)'.format(message))
                }

                return jsonify(xhr_response), 400
            else:
                with_refresh = '[{}](_/verify/)\n\n**Refresh this page after verifying.**'.format(message)

                return render_template('error.html', message=with_refresh, with_retry=True), 400
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号