def post(self, request): res = dict(result=False) if 'id' in request.POST and request.POST['id']: role = get_object_or_404(Role, pk=request.POST.get('id')) else: role = Role() if request.POST.get('title'): role.title = request.POST.get('title') role.save() res['result'] = True return HttpResponse(json.dumps(res), content_type='application/json')
def roleDetailView(request): if request.method == 'GET': ret = dict() if 'id' in request.GET and request.GET['id']: ret = dict(role=get_object_or_404(Role, pk=request.GET.get('id'))) return render(request, 'system/rbac/role_detail.html', ret) else: res = dict(result=False) if 'id' in request.POST and request.POST['id']: role = get_object_or_404(Role, pk=request.POST.get('id')) else: role = Role() if request.POST.get('title'): role.title = request.POST.get('title') role.save() res['result'] = True return HttpResponse(json.dumps(res), content_type='application/json')
] for d in perlistdict: p = Permission() p.title = d[1][0] p.url = d[1][1] p.name = d[1][2] if d[0]: p.menu = Menu.objects.get(title = d[0]) p.save() # 角色 初始化 -- 3个角色(CEO、主管、普通用户) # CEO -- 具有所有权限 r = Role() r.title = 'CEO' r.save() r = Role.objects.get(title = 'CEO') r.permissions.add(Permission.objects.get(title = '首页'),\ Permission.objects.get(title = '帮助文档'),\ Permission.objects.get(title = '上传文件'),\ Permission.objects.get(title = '下载文件'),\ Permission.objects.get(title = '采购列表'),\ Permission.objects.get(title = '添加采购'),\ Permission.objects.get(title = '删除采购'),\ Permission.objects.get(title = '修改采购'),\ Permission.objects.get(title = '批量采购导入'),\ Permission.objects.get(title = '下载采购模板'),\ Permission.objects.get(title = '送货列表'),\