(request)
return ajax_success(msg=f"{len(copied)} files copied.")
Add file from import root directory into clipboard.
Add file from import root directory into clipboard.
Add file from import root directory into clipboard .
def copy_file(request):
    """
    Add file from import root directory into clipboard.
    """
    # Assumes incoming path is a full path
    path = request.POST.get('path')
    user = request.user

    # Project uid to check access
    uid = request.POST.get('uid') or 0
    project = Project.objects.filter(id=uid).first()

    if uid and not project:
        return ajax_error(msg="Project does not exist.")

    if project and not auth.is_readable(user=user, obj=project):
        return ajax_error(msg="You do not have access to copy this file")

    if not os.path.exists(path):
        return ajax_error(msg="File path does not exist.")

    if path.startswith(settings.IMPORT_ROOT_DIR) and not user.profile.trusted:
        return ajax_error(msg="Only trusted users can copy from this directory.")

    copied = auth.copy_file(request=request, fullpath=path)
    return ajax_success(msg=f"{len(copied)} files copied.")
def copy_file ( request ) : # Assumes incoming path is a full path path = request . POST . get ( 'path' ) user = request . user # Project uid to check access uid = request . POST . get ( 'uid' ) or 0 project = Project . objects . filter ( id = uid ) . first ( ) if uid and not project : return ajax_error ( msg = "Project does not exist." ) if project and not auth . is_readable ( user = user , obj = project ) : return ajax_error ( msg = "You do not have access to copy this file" ) if not os . path . exists ( path ) : return ajax_error ( msg = "File path does not exist." ) if path . startswith ( settings . IMPORT_ROOT_DIR ) and not user . profile . trusted : return ajax_error ( msg = "Only trusted users can copy from this directory." ) copied = auth . copy_file ( request = request , fullpath = path ) return ajax_success ( msg = f"{len(copied)} files copied." )