示例#1
0
文件: group.py 项目: frecar/focus
def permissions(request, id):
    group = Group.objects.filter_current_company().get(id=id)

     #Save and set to active, require valid form
    if request.method == 'POST':
        permission_form = PermissionForm(request.POST, instance=Permission())
        if permission_form.is_valid():
            perm = permission_form.save(commit=False)
            perm.group = group
            perm.save()

    else:
        permission_form = PermissionForm(instance=Permission())

    return render(request, 'admin/permissions.html', {'title': _("Groups"),
                                                      'group': group,
                                                      'form': permission_form,                                                      
                                                      'permissions': group.get_permissions(),
                                                      })
示例#2
0
文件: user.py 项目: frecar/focus
def permissions(request, id):
    user = User.objects.get(id=id)
    Permissions = user.get_permissions().order_by("group", "content_type", "object_id")

    #Save and set to active, require valid form
    if request.method == 'POST':
        permission_form = PermissionForm(request.POST, instance=Permission())
        if permission_form.is_valid():
            perm = permission_form.save(commit=False)
            perm.user = user
            perm.save()

    else:
        permission_form = PermissionForm(instance=Permission())

    return render(request, 'admin/permissions.html', {'title': _("Permissions for %s" % user),
                                                      'userCard': user,
                                                      'form': permission_form,
                                                      'permissions': Permissions,
                                                      })
示例#3
0
文件: group.py 项目: bopopescu/focus
def permissions(request, id):
    group = Group.objects.filter_current_company().get(id=id)

    #Save and set to active, require valid form
    if request.method == 'POST':
        permission_form = PermissionForm(request.POST, instance=Permission())
        if permission_form.is_valid():
            perm = permission_form.save(commit=False)
            perm.group = group
            perm.save()

    else:
        permission_form = PermissionForm(instance=Permission())

    return render(
        request, 'admin/permissions.html', {
            'title': _("Groups"),
            'group': group,
            'form': permission_form,
            'permissions': group.get_permissions(),
        })