(request)
return ajax_success(f"Copied. Clipboard contains :{len(copied)} objects.")
Add object uid or file path to sessions clipboard.
Add object uid or file path to sessions clipboard.
Add object uid or file path to sessions clipboard .
def copy_object(request):
    """
    Add object uid or file path to sessions clipboard.
    """
    # Map the query parameter to a clipboard and database model.
    mapper = {"data": (Data, COPIED_DATA),  "job": (Job, COPIED_RESULTS), "recipe": (Analysis, COPIED_RECIPES)}
    uid = request.POST.get('uid', '')
    oid = request.POST.get('id', 0)

    # Get the clipboard to copy to
    clipboard = request.POST.get(settings.CLIPBOARD_NAME)

    klass, board = mapper.get(clipboard, (None, None))
    if uid:
        obj = klass.objects.filter(uid=uid).first()
    else:
        obj = klass.objects.filter(id=oid).first()

    if not (klass and board and obj):
        return ajax_error("Object or board does not exist.")

    is_readable = auth.is_readable(user=request.user, obj=obj)

    if not is_readable:
        return ajax_error('You do not have access to copy this object.')

    # Return current clipboard contents
    copied = auth.copy_uid(request=request, uid=obj.uid, board=board)

    return ajax_success(f"Copied. Clipboard contains :{len(copied)} objects.")
def copy_object ( request ) : # Map the query parameter to a clipboard and database model. mapper = { "data" : ( Data , COPIED_DATA ) , "job" : ( Job , COPIED_RESULTS ) , "recipe" : ( Analysis , COPIED_RECIPES ) } uid = request . POST . get ( 'uid' , '' ) oid = request . POST . get ( 'id' , 0 ) # Get the clipboard to copy to clipboard = request . POST . get ( settings . CLIPBOARD_NAME ) klass , board = mapper . get ( clipboard , ( None , None ) ) if uid : obj = klass . objects . filter ( uid = uid ) . first ( ) else : obj = klass . objects . filter ( id = oid ) . first ( ) if not ( klass and board and obj ) : return ajax_error ( "Object or board does not exist." ) is_readable = auth . is_readable ( user = request . user , obj = obj ) if not is_readable : return ajax_error ( 'You do not have access to copy this object.' ) # Return current clipboard contents copied = auth . copy_uid ( request = request , uid = obj . uid , board = board ) return ajax_success ( f"Copied. Clipboard contains :{len(copied)} objects." )