Example #1
0
def manage_access(request, project):
    """User management view."""
    obj = get_project(request, project)

    if not can_manage_acl(request.user, obj):
        raise PermissionDenied()

    return render(
        request, 'manage-access.html', {
            'object': obj,
            'project': obj,
            'groups': obj.all_groups(),
            'add_user_form': UserManageForm(),
        })
Example #2
0
File: acl.py Project: saily/weblate
def manage_access(request, project):
    """User management view."""
    obj = get_project(request, project)

    if not can_manage_acl(request.user, obj):
        raise PermissionDenied()

    return render(
        request,
        'manage-access.html',
        {
            'object': obj,
            'project': obj,
            'groups': obj.all_groups(),
            'add_user_form': UserManageForm(),
        }
    )
Example #3
0
def check_user_form(request, project, verbose=False):
    """Check project permission and UserManageForm.

    This is simple helper to perform needed validation for all
    user management views.
    """
    obj = get_project(request, project)

    if not can_manage_acl(request.user, obj):
        raise PermissionDenied()

    form = UserManageForm(request.POST)

    if form.is_valid():
        return obj, form
    elif verbose:
        for error in form.errors:
            for message in form.errors[error]:
                messages.error(request, message)
    return obj, None
Example #4
0
File: acl.py Project: saily/weblate
def check_user_form(request, project, verbose=False):
    """Check project permission and UserManageForm.

    This is simple helper to perform needed validation for all
    user management views.
    """
    obj = get_project(request, project)

    if not can_manage_acl(request.user, obj):
        raise PermissionDenied()

    form = UserManageForm(request.POST)

    if form.is_valid():
        return obj, form
    elif verbose:
        for error in form.errors:
            for message in form.errors[error]:
                messages.error(request, message)
    return obj, None
Example #5
0
def manage_access(request, project):
    """User management view."""
    obj = get_project(request, project)

    if not can_manage_acl(request.user, obj):
        raise PermissionDenied()

    if can_edit_access_control(request.user, obj):
        access_form = ProjectAccessForm(instance=obj)
    else:
        access_form = DisabledProjectAccessForm(instance=obj)

    return render(
        request, 'manage-access.html', {
            'object': obj,
            'project': obj,
            'groups': obj.all_groups(),
            'add_user_form': UserManageForm(),
            'access_form': access_form,
        })