24-----BBS论坛

BBS论坛(二十四)

24.1.编辑板块

cms/js/banners.js

复制代码
$(function () {
    $('.edit-board-btn').click(function () {
        var self = $(this);
        var tr = self.parent().parent();
        var name = tr.attr('data-name');
        var board_id = tr.attr('data-id');

        zlalert.alertOneInput({
            'title': '编辑板块',
            'text': '请输入版块名称',
            'placeholder': name,
            'confirmCallback': function (inputValue) {
                zlajax.post({
                    'url': '/cms/uboards/',
                    'data': {
                        'board_id': board_id,
                        'name': inputValue
                    },
                    'success': function (data) {
                        if (data['code'] == 200) {
                            window.location.reload();
                        } else {
                            zlalert.alertInfo(data['message'])
                        }
                    }
                });
            }
        });

    });
});
复制代码

24.2.删除板块

cms/js/banners.js

复制代码
$(function () {
    $('.delete-board-btn').click(function (event) {
        event.preventDefault();
        var self = $(this);
        var board_id = self.parent().parent().attr('data-id');
        zlalert.alertConfirm({
            'title': '删除版块',
            'msg': '确认删除该版块吗?',
            'confirmCallback': function () {
                zlajax.post({
                    'url': '/cms/dboards/',
                    'data': {
                        'board_id': board_id
                    },
                    'success': function (data) {
                        if (data['code'] == 200) {
                            window.location.reload();
                        } else {
                            zlalert.alertInfo(data['message']);
                        }
                    }
                });
            }
        })
    })
});
复制代码

24.3.首页动态显示板块

(1)front/views.py

复制代码
@bp.route('/')
def index():
    banners = BannerModel.query.order_by(BannerModel.priority.desc()).limit(4)
    boards = BoardModel.query.all()
    context = {
        'banners':banners,
        'boards':boards
    }
    return render_template('front/front_index.html',**context)
复制代码

(2)front/index.py

复制代码
 <div class="sm-container">
            <div style="margin-bottom: 10px;">
                <button class="btn btn-warning btn-block">发布帖子</button>
            </div>


            <div class="list-group">
                <a href="#" class="list-group-item active">所有板块</a>

                {% for board in boards %}
                    <a href="#" class="list-group-item">{{ board.name }}</a>
                {% endfor %}
            </div>
        </div>
复制代码

 

posted @   王竹笙  阅读(320)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
点击右上角即可分享
微信分享提示