Пример #1
0
def folder_edit(request, folder_id, response_format='html'):
    "Folder edit page"

    folder = get_object_or_404(Folder, pk=folder_id)

    if not request.user.get_profile().has_permission(folder, mode='w'):
        return user_denied(request, message="You don't have access to this Folder")

    if request.POST:
        if not 'cancel' in request.POST:
            form = FolderForm(
                request.user.get_profile(), folder_id, request.POST, instance=folder)
            if form.is_valid():
                folder = form.save()
                return HttpResponseRedirect(reverse('documents_folder_view', args=[folder.id]))
        else:
            return HttpResponseRedirect(reverse('documents_folder_view', args=[folder.id]))

    else:
        form = FolderForm(
            request.user.get_profile(), folder_id, instance=folder)

    context = _get_default_context(request)
    context.update({'form': form,
                    'folder': folder})

    return render_to_response('documents/folder_edit', context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
Пример #2
0
def folder_add_typed(request, folder_id=None, response_format='html'):
    "Folder add to preselected folder"

    folder = None
    if folder_id:
        folder = get_object_or_404(Folder, pk=folder_id)
        if not request.user.get_profile().has_permission(folder, mode='x'):
            folder = None

    if request.POST:
        if not 'cancel' in request.POST:
            folder = Folder()
            form = FolderForm(
                request.user.get_profile(), folder_id, request.POST, instance=folder)
            if form.is_valid():
                folder = form.save()
                folder.set_user_from_request(request)
                return HttpResponseRedirect(reverse('documents_folder_view', args=[folder.id]))
        else:
            return HttpResponseRedirect(reverse('document_index'))
    else:
        form = FolderForm(request.user.get_profile(), folder_id)

    context = _get_default_context(request)
    context.update({'form': form,
                    'folder': folder})

    return render_to_response('documents/folder_add_typed', context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
Пример #3
0
def folder_edit(request, folder_id, response_format='html'):
    "Folder edit page"

    folder = get_object_or_404(Folder, pk=folder_id)

    if not request.user.get_profile().has_permission(folder, mode='w'):
        return user_denied(request,
                           message="You don't have access to this Folder")

    if request.POST:
        if not 'cancel' in request.POST:
            form = FolderForm(request.user.get_profile(),
                              folder_id,
                              request.POST,
                              instance=folder)
            if form.is_valid():
                folder = form.save()
                return HttpResponseRedirect(
                    reverse('documents_folder_view', args=[folder.id]))
        else:
            return HttpResponseRedirect(
                reverse('documents_folder_view', args=[folder.id]))

    else:
        form = FolderForm(request.user.get_profile(),
                          folder_id,
                          instance=folder)

    context = _get_default_context(request)
    context.update({'form': form, 'folder': folder})

    return render_to_response('documents/folder_edit',
                              context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
Пример #4
0
def folder_add_typed(request, folder_id=None, response_format='html'):
    "Folder add to preselected folder"

    folder = None
    if folder_id:
        folder = get_object_or_404(Folder, pk=folder_id)
        if not request.user.get_profile().has_permission(folder, mode='x'):
            folder = None

    if request.POST:
        if not 'cancel' in request.POST:
            folder = Folder()
            form = FolderForm(request.user.get_profile(),
                              folder_id,
                              request.POST,
                              instance=folder)
            if form.is_valid():
                folder = form.save()
                folder.set_user_from_request(request)
                return HttpResponseRedirect(
                    reverse('documents_folder_view', args=[folder.id]))
        else:
            return HttpResponseRedirect(reverse('document_index'))
    else:
        form = FolderForm(request.user.get_profile(), folder_id)

    context = _get_default_context(request)
    context.update({'form': form, 'folder': folder})

    return render_to_response('documents/folder_add_typed',
                              context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
Пример #5
0
def folder_add(request, response_format='html'):
    "New folder form"

    if request.POST:
        if not 'cancel' in request.POST:
            folder = Folder()
            form = FolderForm(request.user.get_profile(),
                              None,
                              request.POST,
                              instance=folder)
            if form.is_valid():
                folder = form.save()
                folder.set_user_from_request(request)
                return HttpResponseRedirect(
                    reverse('documents_folder_view', args=[folder.id]))
        else:
            return HttpResponseRedirect(reverse('document_index'))
    else:
        form = FolderForm(request.user.get_profile(), None)

    context = _get_default_context(request)
    context.update({'form': form})

    return render_to_response('documents/folder_add',
                              context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
Пример #6
0
def folder_add(request, response_format='html'):
    "New folder form"

    if request.POST:    
        if not 'cancel' in request.POST:
            folder = Folder()
            form = FolderForm(request.user.get_profile(), None, request.POST, instance=folder)
            if form.is_valid():
                folder = form.save()
                folder.set_user_from_request(request)
                return HttpResponseRedirect(reverse('documents_folder_view', args=[folder.id]))
        else:
            return HttpResponseRedirect(reverse('document_index'))
    else:
        form = FolderForm(request.user.get_profile(), None)
        
    context = _get_default_context(request)
    context.update({'form': form}) 
    
    return render_to_response('documents/folder_add', context,
                              context_instance=RequestContext(request),
                              response_format=response_format)