Esempio n. 1
0
File: views.py Progetto: kamni/zorna
def admin_edit_folder(request, folder):
    if request.user.is_superuser:
        c = ZornaFolder.objects.get(pk=folder)
        if request.method == 'POST':
            form = ZornaFolderForm(request.POST, instance=c)
            if request.POST.has_key('bdelete'):
                fullpath = u"%s/%s" % (get_upload_library(), u"F%s" % c.pk)
                bexist = os.path.isdir(fullpath)
                if not bexist or not os.listdir(fullpath):
                    if bexist:
                        os.rmdir(fullpath)
                    c.delete()
                    return HttpResponseRedirect(reverse('admin_list_folders'))

            if form.is_valid():
                form.save()
                return HttpResponseRedirect(reverse('admin_list_folders'))
        else:
            form = ZornaFolderForm(instance=c)

        fullpath = u"%s/%s" % (get_upload_library(), u"F%s" % c.pk)
        if not os.path.isdir(fullpath) or not os.listdir(fullpath):
            bdelete = True
        else:
            bdelete = False

        context = RequestContext(request)
        extra_context = {'form': form, 'curfolder': c, 'bdelete': bdelete}
        return render_to_response('fileman/edit_folder.html', extra_context, context_instance=context)
    else:
        return HttpResponseRedirect('/')
Esempio n. 2
0
def admin_edit_folder(request, folder):
    if request.user.is_superuser:
        c = ZornaFolder.objects.get(pk=folder)
        if request.method == 'POST':
            form = ZornaFolderForm(request.POST, instance=c)
            if request.POST.has_key('bdelete'):
                fullpath = u"%s/%s" % (get_upload_library(), u"F%s" % c.pk)
                bexist = os.path.isdir(fullpath)
                if not bexist or not os.listdir(fullpath):
                    if bexist:
                        os.rmdir(fullpath)
                    c.delete()
                    return HttpResponseRedirect(reverse('admin_list_folders'))

            if form.is_valid():
                form.save()
                return HttpResponseRedirect(reverse('admin_list_folders'))
        else:
            form = ZornaFolderForm(instance=c)

        fullpath = u"%s/%s" % (get_upload_library(), u"F%s" % c.pk)
        if not os.path.isdir(fullpath) or not os.listdir(fullpath):
            bdelete = True
        else:
            bdelete = False

        context = RequestContext(request)
        extra_context = {'form': form, 'curfolder': c, 'bdelete': bdelete}
        return render_to_response('fileman/edit_folder.html', extra_context, context_instance=context)
    else:
        return HttpResponseRedirect('/')
Esempio n. 3
0
File: views.py Progetto: kamni/zorna
def admin_add_folder(request):
    if request.user.is_superuser:
        if request.method == 'POST':
            form = ZornaFolderForm(request.POST)
            if form.is_valid():
                category = form.save(commit=False)
                category.owner = request.user
                category.save()
                return HttpResponseRedirect(reverse('admin_list_folders'))
            else:
                form = ZornaFolderForm(request.POST)
        else:
            form = ZornaFolderForm()

        context = RequestContext(request)
        extra_context = {'form': form, 'curfolder': False}
        return render_to_response('fileman/edit_folder.html', extra_context, context_instance=context)
    else:
        return HttpResponseRedirect('/')
Esempio n. 4
0
def admin_add_folder(request):
    if request.user.is_superuser:
        if request.method == 'POST':
            form = ZornaFolderForm(request.POST)
            if form.is_valid():
                category = form.save(commit=False)
                category.owner = request.user
                category.save()
                return HttpResponseRedirect(reverse('admin_list_folders'))
            else:
                form = ZornaFolderForm(request.POST)
        else:
            form = ZornaFolderForm()

        context = RequestContext(request)
        extra_context = {'form': form, 'curfolder': False}
        return render_to_response('fileman/edit_folder.html', extra_context, context_instance=context)
    else:
        return HttpResponseRedirect('/')