Exemple #1
0
def edit_permissions(request, p_id, user_id):

    project = get_object_or_404(Project, id=p_id)
    edit_user = get_object_or_404(User, id=user_id)
    project.check_user_in_project_or_404(edit_user)

    #dont' edit permissions of admin
    if edit_user.is_superuser:
        return HttpResponseRedirect(
            urlresolvers.reverse('rancho.project.views.show_people_project',
                                 args=[project.id]))

    if request.method == 'POST':
        form = EditPermissionsForm(request.POST)
        if form.is_valid():

            form.save(edit_user, project)
            request.user.message_set.create(message=_("Permissions updated"))

            return HttpResponseRedirect(
                urlresolvers.reverse(
                    'rancho.project.views.show_people_project',
                    args=[project.id]))
    else:
        perm = permissions.get_permission_dictionary(edit_user, project)
        form = EditPermissionsForm({'permissions': perm})

    return render_to_response('project/edit_permissions.html', {
        'edit_user': edit_user,
        'project': project,
        'form': form,
    },
                              context_instance=RequestContext(request))
Exemple #2
0
def edit_permissions(request, p_id, user_id):

    project = get_object_or_404(Project, id=p_id)
    edit_user = get_object_or_404(User, id=user_id)
    project.check_user_in_project_or_404(edit_user)

    #dont' edit permissions of admin
    if edit_user.is_superuser:
        return HttpResponseRedirect(urlresolvers.reverse('rancho.project.views.show_people_project', args=[project.id]))

    if request.method=='POST':
        form = EditPermissionsForm(request.POST)
        if form.is_valid():

            form.save(edit_user, project)
            request.user.message_set.create(message=_("Permissions updated"))

            return HttpResponseRedirect(urlresolvers.reverse('rancho.project.views.show_people_project', args=[project.id]))
    else:
        perm = permissions.get_permission_dictionary(edit_user, project)
        form = EditPermissionsForm({'permissions': perm})



    return render_to_response('project/edit_permissions.html',
                              {'edit_user': edit_user,
                               'project': project,
                               'form': form,
                               },
                              context_instance=RequestContext(request))
Exemple #3
0
def serializeUsersInProject(element, project):
    users_in_project = UserInProject.objects.filter(project = project)
    if not users_in_project:
        return
    users_in_project_element = ET.SubElement(element, 'users', {'type': 'list'})
    for user_in_project in users_in_project:
        user_in_project_element = serialize(user_in_project)
        users_in_project_element.append(user_in_project_element)
        permission_dict = get_permission_dictionary(user_in_project.user, project)
        permissions_element = ET.SubElement(user_in_project_element, 'permissions', {'type': 'list'})
        for key in permission_dict.keys():
            permission_element = ET.SubElement(permissions_element, key, {'type': 'text'})
            permission_element.text = permission_dict[key]
Exemple #4
0
def serializeUsersInProject(element, project):
    users_in_project = UserInProject.objects.filter(project=project)
    if not users_in_project:
        return
    users_in_project_element = ET.SubElement(element, 'users',
                                             {'type': 'list'})
    for user_in_project in users_in_project:
        user_in_project_element = serialize(user_in_project)
        users_in_project_element.append(user_in_project_element)
        permission_dict = get_permission_dictionary(user_in_project.user,
                                                    project)
        permissions_element = ET.SubElement(user_in_project_element,
                                            'permissions', {'type': 'list'})
        for key in permission_dict.keys():
            permission_element = ET.SubElement(permissions_element, key,
                                               {'type': 'text'})
            permission_element.text = permission_dict[key]