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(), })
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, })
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(), })