(request, path="")
return render(request, 'import_files.html', context=context)
Import files mounted on IMPORT_ROOT_DIR in settings
Import files mounted on IMPORT_ROOT_DIR in settings
Import files mounted on IMPORT_ROOT_DIR in settings
def import_files(request, path=""):
    """
    Import files mounted on IMPORT_ROOT_DIR in settings
    """
    user = request.user
    if not user.profile.trusted:
        messages.error(request, 'Only trusted users may views this page.')
        return redirect(reverse('project_list'))

    root = settings.IMPORT_ROOT_DIR
    path = os.path.abspath(os.path.join(root, path))
    if not path.startswith(root):
        messages.error(request, 'Outside root directory')
        path = ''

    if not os.path.exists(path):
        messages.error(request, 'File path does not exist')
        path = ''

    # Set the current node we are traversing.
    node = path if os.path.isdir(path) else None

    # Walk through the /root/node/ and collect paths.
    # Directories are not walked through because show_all=False.
    paths = auth.listing(root=root, node=node, show_all=False)

    context = dict(paths=paths, active="import", show_all=False)

    return render(request, 'import_files.html', context=context)
def import_files ( request , path = "" ) : user = request . user if not user . profile . trusted : messages . error ( request , 'Only trusted users may views this page.' ) return redirect ( reverse ( 'project_list' ) ) root = settings . IMPORT_ROOT_DIR path = os . path . abspath ( os . path . join ( root , path ) ) if not path . startswith ( root ) : messages . error ( request , 'Outside root directory' ) path = '' if not os . path . exists ( path ) : messages . error ( request , 'File path does not exist' ) path = '' # Set the current node we are traversing. node = path if os . path . isdir ( path ) else None # Walk through the /root/node/ and collect paths. # Directories are not walked through because show_all=False. paths = auth . listing ( root = root , node = node , show_all = False ) context = dict ( paths = paths , active = "import" , show_all = False ) return render ( request , 'import_files.html' , context = context )