权限分配实现思路

先上一张,效果图。 OK
开始做:
用户信息  和 角色。很容易就能搞成。 只需要从数据库取出。 menu  和 role 两张表的全部数据, 再模板进行循环的渲染就行了。

    all_user_queryset = models.UserInfo.objects.all()
    all_role_queryset = models.Role.objects.all()

 拿到数据,前端直接渲染就好了!

{% extends "layout.html" %}
{% block css %}
    <style type="text/css">
        tr.active {
            border-left: #eea236 solid 2px;
        }
    </style>
{% endblock %}
{% load rbac_tags %}
{% block content %}
    <div class="luffy-container">
        <div class="col-md-3">
            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading"><i class="fa fa-book" aria-hidden="true"></i>员工信息</div>
                <div class="panel panel-body">
                    <ul>
                        {% for user in all_user_list %}
                            <li><a href="">{{ user.name }}</a></li>
                        {% endfor %}
                    </ul>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="panel panel-default">
                <div class="panel-heading"><i class="fa fa-binoculars" aria-hidden="true"></i>角色信息</div>
                <div class="panel panel-body">
                提示:点击用户后才能为其分配角色
                    <table class="table table-condensed">
                        <thead>
                        <tr>
                            <th>角色</th>
                            <th>选项</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% for role in all_role_list %}
                            <tr>
                                <td><a href="">{{role.title}}</a></td>
                                <td><input type="checkbox" name="roles" value="{{ role.id }}"></td>
                            </tr>
                        {% endfor %}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
这部分,我也没搞 样式!  看自己心情!

相关文章:

  • 2021-10-18
  • 2022-12-23
  • 2022-12-23
  • 2021-09-19
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
猜你喜欢
  • 2021-12-16
  • 2021-08-30
  • 2021-11-03
  • 2021-08-12
  • 2022-02-15
  • 2021-05-22
相关资源
相似解决方案