Exemplo n.º 1
0
def new_folder(request):
    form = FolderForm(request.POST)
    if form.is_valid():
        form.instance.user = request.user
        folder = form.save()
        dump = json.dumps({ 'folder': { 'id': folder.id, 'name': folder.name, 'slug': folder.slug } })
        return HttpResponse(dump, content_type='application/json')
    else:
        dump = json.dumps(form.errors)
        return HttpResponseBadRequest(dump, content_type='application/json')
Exemplo n.º 2
0
def new_folder(request):
    form = FolderForm(request.POST)
    if form.is_valid():
        form.instance.user = request.user
        folder = save_folder(form)
        dump = json.dumps({"folder": {"id": folder.id, "name": folder.name, "slug": folder.slug}})
        return HttpResponse(dump, content_type="application/json")
    else:
        dump = json.dumps(form.errors)
        return HttpResponseBadRequest(dump, content_type="application/json")
Exemplo n.º 3
0
def new_folder(request):
    form = FolderForm(request.POST)
    if form.is_valid():
        form.instance.user = request.user
        folder = form.save()
        dump = json.dumps({
            'folder': {
                'id': folder.id,
                'name': folder.name,
                'slug': folder.slug
            }
        })
        return HttpResponse(dump, content_type='application/json')
    else:
        dump = json.dumps(form.errors)
        return HttpResponseBadRequest(dump, content_type='application/json')
Exemplo n.º 4
0
def edit_folder(request):
    delete_folder = request.POST.get('delete', '') == 'delete'
    folder_id = request.POST.get('id')
    folder = Folder.objects.get(pk=folder_id)
    if delete_folder:
        folder.delete()
        messages.success(request, u'The folder {0} was deleted successfully!'.format(folder.name))
        return redirect(r('library:index'))
    else:    
        form = FolderForm(request.POST, instance=folder)
        if form.is_valid():
            form.instance.user = request.user
            folder = form.save()
            messages.success(request, u'The folder {0} was changed successfully!'.format(folder.name))
        else:
            messages.error(request, u'An error ocurred while trying to save folder {0}'.format(folder.name))
    return redirect(r('library:folder', args=(folder.slug,)))
Exemplo n.º 5
0
def edit_folder(request):
    deleteFolder = request.POST.get("delete", "") == "delete"
    folder_id = request.POST.get("id")
    folder = Folder.objects.get(pk=folder_id)
    if deleteFolder:
        folder.delete()
        messages.success(request, u"The folder {0} was deleted successfully!".format(folder.name))
        return redirect(r("library:index"))
    else:
        form = FolderForm(request.POST, instance=folder)
        if form.is_valid():
            form.instance.user = request.user
            folder = save_folder(form)
            messages.success(request, u"The folder {0} was changed successfully!".format(folder.name))
        else:
            messages.error(request, u"An error ocurred while trying to save folder {0}".format(folder.name))
    return redirect(r("library:folder", args=(folder.slug,)))
Exemplo n.º 6
0
def edit_folder(request):
    delete_folder = request.POST.get('delete', '') == 'delete'
    folder_id = request.POST.get('id')
    folder = Folder.objects.get(pk=folder_id)
    if delete_folder:
        folder.delete()
        messages.success(
            request,
            u'The folder {0} was deleted successfully!'.format(folder.name))
        return redirect(r('library:index'))
    else:
        form = FolderForm(request.POST, instance=folder)
        if form.is_valid():
            form.instance.user = request.user
            folder = form.save()
            messages.success(
                request, u'The folder {0} was changed successfully!'.format(
                    folder.name))
        else:
            messages.error(
                request,
                u'An error ocurred while trying to save folder {0}'.format(
                    folder.name))
    return redirect(r('library:folder', args=(folder.slug, )))
Exemplo n.º 7
0
def library(request, documents, querystring, order, active_folder=None):
    reviews = Review.objects.filter(author=request.user)
    folder_form = FolderForm(initial={'user': request.user})
    shared_folder_form = SharedFolderForm()
    current_full_path = request.get_full_path()
    return render(
        request, 'library/library.html', {
            'reviews': reviews,
            'documents': documents,
            'querystring': querystring,
            'order': order,
            'active_folder': active_folder,
            'folder_form': folder_form,
            'shared_folder_form': shared_folder_form,
            'current_full_path': current_full_path
        })