Exemple #1
0
def role_edit(id):
    role = Role.get_by_id(id)
    menus = Role.get_menu_for_role()
    temp = []
    for menu in menus:
        menu.checkbox = False
        permissions = menu.permissions
        if permissions:
            for permission in permissions:
                if role in permission.roles:
                    menu.checkbox = True
                    break
        temp.append(menu)

    permission_ids = []
    if role.permissions:
        for permission in role.permissions:
            permission_ids.append(permission.id)

    return render_template('admin/role/edit.html',
                           role=role,
                           menus=temp,
                           permission_ids=permission_ids)
Exemple #2
0
def role_create():
    menus = Role.get_menu_for_role()
    return render_template('admin/role/create.html', menus=menus)