def remove_user_from_project(request, projectID, username):
    p = project_api.get_project(projectID)
    if request.method == 'POST':
        form = SelectAccessLevelForm()
        project_api.remove_user_from_project(projectID, username)
    else:
        form = SelectAccessLevelForm()
    users = p.users.all()
    users = users.exclude(username=request.user.username)

    context = {
        'title': 'Remove User from Project',
        'form': form,
        'project': p,
        'users': users,
        'confirm_message': 'This is an unrevert procedure ! This user will lose the permission to access this project !',
    }

    return render(request, 'UserSummary.html', context)
示例#2
0
def add_user_to_project(request, projectID, username):
    project = project_api.get_project(projectID)
    if request.method == 'POST':
        form = SelectAccessLevelForm(request.POST)
        if form.is_valid():
            user_role = (request.POST).get('user_role', '')
            project_api.add_user_to_project(projectID, username, user_role)
    else:
        form = SelectAccessLevelForm()

    users = user_manager.getActiveUsers()
    for puser in project.users.all():
        users = users.exclude(username=puser.username)
    context = {
        'title': 'Add User to Project',
        'form': form,
        'project': project,
        'users': users,
    }

    return render(request, 'UserSummary.html', context)
示例#3
0
def add_user_to_project(request, projectID, username):
    project = project_api.get_project(projectID)
    if request.method == 'POST':
        form = SelectAccessLevelForm(request.POST)
        if form.is_valid():
            user_role = (request.POST).get('user_role', '')
            project_api.add_user_to_project(projectID, username, user_role)
    else:
        form = SelectAccessLevelForm()

    users = user_manager.getActiveUsers()
    for puser in project.users.all():
        users = users.exclude(username=puser.username)
    context = {
        'title': 'Add User to Project',
        'form': form,
        'project': project,
        'users': users,
    }

    return render(request, 'UserSummary.html', context)
def manage_user_association(request, projectID, userID):
    form = SelectAccessLevelForm()
    p = project_api.get_project(projectID)
    the_user = User.objects.get(id=userID)
    association = UserAssociation.objects.get(user=the_user, project=p)
    role = association.role

    context = {
        'title': 'Change User Access Level',
        'form': form,
        'project': p,
        'user': the_user,
        'role': role,
    }
    return render(request, 'ManageUserAssociation.html', context)