def apply_option_post(request): if not request.method == 'POST': return HttpResponseNotAllowed(['POST']) path = request.POST.get('relative_h', None) name = request.POST.get('name_h', None) option = request.POST.get('option_h', None) typ = request.POST.get('type_h', None) if not (name and path and option and typ): return HttpResponseBadRequest() if typ == 'directory': path = '.' fb = Filebrowser(path=path) try: if typ == "entry": return ENTRY_OPTIONS[int(option)].process_option( request, fb, name, ) else: return DIRECTORY_OPTIONS[int(option)].process_option( request, fb, name) except Exception as e: messages.error( request, "Impossible to apply the option " + option + " : " + str(type(e)).replace('<', '[').replace('>', ']') + " - " + str(e)) return redirect_fb(path)
def index(request): """ Used by the filebrowser module to navigate """ if request.method == 'GET': path = request.GET.get('cd', '.') return render(request, 'filebrowser/filebrowser.html', {'fb': Filebrowser(path=path)})
def apply_option_post(request): """ Apply an option using the POST method """ if not request.method == 'POST': return HttpResponseNotAllowed(['POST']) path = request.POST.get('relative_h', None) name = request.POST.get('name_h', None) option = request.POST.get('option_h', None) typ = request.POST.get('type_h', None) if not (name and path and option and typ): return HttpResponseBadRequest( "Missing one of 'relative_h', 'name_h', 'option_h' or 'type_h' argument" ) if typ == 'directory': path = '.' fb = Filebrowser(path=path) try: if typ == "entry": return ENTRY_OPTIONS[option].process_option( request, fb, name, ) else: return DIRECTORY_OPTIONS[option].process_option(request, fb, name) except Exception as e: messages.error( request, "Impossible to apply the option " + option + " : " + htmlprint.code(str(type(e)) + " - " + str(e))) return redirect_fb(path)
def index(request): if request.method == 'GET': path = request.GET.get('cd', '.') return render(request, 'filebrowser/filebrowser.html', {'fb': Filebrowser(path=path)})