(request)
return ajax_success(msg=f"Pasted {count} items into project.", redirect=next_url)
Paste the most recent
Paste the most recent
Paste the most recent
def ajax_paste(request):
    """
    Paste the most recent
    """
    pid = request.POST.get("id", 0)
    user = request.user
    project = Project.objects.filter(id=pid).first()

    # Get the board.
    board = auth.recent_clipboard(request=request)
    key, vals = board
    count = len(vals)

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

    if not auth.is_writable(user=user, project=project):
        return ajax_error(msg="You do not have access to paste here.")

    if not count:
        return ajax_error(msg="Clipboard is empty")

    # The target of this action is to clone.
    clone = request.POST.get('target') == CLONED_RECIPES

    # Paste the clipboard item into the project
    auth.paste(board=board, user=user, project=project, clone=clone)

    # Resolve the redirect url.
    next_url = auth.resolve_paste_url(key=key, project=project)

    # Clear the clipboard after pasting.
    auth.clear(request=request)

    return ajax_success(msg=f"Pasted {count} items into project.", redirect=next_url)
def ajax_paste ( request ) : pid = request . POST . get ( "id" , 0 ) user = request . user project = Project . objects . filter ( id = pid ) . first ( ) # Get the board. board = auth . recent_clipboard ( request = request ) key , vals = board count = len ( vals ) if not project : return ajax_error ( msg = "Project does not exist." ) if not auth . is_writable ( user = user , project = project ) : return ajax_error ( msg = "You do not have access to paste here." ) if not count : return ajax_error ( msg = "Clipboard is empty" ) # The target of this action is to clone. clone = request . POST . get ( 'target' ) == CLONED_RECIPES # Paste the clipboard item into the project auth . paste ( board = board , user = user , project = project , clone = clone ) # Resolve the redirect url. next_url = auth . resolve_paste_url ( key = key , project = project ) # Clear the clipboard after pasting. auth . clear ( request = request ) return ajax_success ( msg = f"Pasted {count} items into project." , redirect = next_url )