Esempio n. 1
0
def folder_new_post(auth, node, **kwargs):
    user = auth.user

    title = request.json.get("title")

    if not node.is_folder:
        raise HTTPError(http.BAD_REQUEST)
    folder = new_folder(strip_html(title), user)
    folders = [folder]
    try:
        _add_pointers(node, folders, auth)
    except ValueError:
        raise HTTPError(http.BAD_REQUEST)

    return {"projectUrl": "/dashboard/"}, http.CREATED
Esempio n. 2
0
def add_folder(**kwargs):
    auth = kwargs['auth']
    user = auth.user
    title = strip_html(request.json.get('title'))
    node_id = request.json.get('node_id')
    node = Node.load(node_id)
    if node.is_deleted or node.is_registration or not node.is_folder:
        raise HTTPError(http.BAD_REQUEST)

    folder = new_folder(title, user)
    folders = [folder]
    try:
        _add_pointers(node, folders, auth)
    except ValueError:
        raise HTTPError(http.BAD_REQUEST)
    return {}, 201, None
Esempio n. 3
0
def add_folder(auth, **kwargs):
    data = request.get_json()
    node_id = data.get('node_id')
    node = get_or_http_error(Node, node_id)

    user = auth.user
    title = strip_html(data.get('title'))
    if not node.is_folder:
        raise HTTPError(http.BAD_REQUEST)

    folder = new_folder(title, user)
    folders = [folder]
    try:
        _add_pointers(node, folders, auth)
    except ValueError:
        raise HTTPError(http.BAD_REQUEST)
    return {}, 201, None
Esempio n. 4
0
def folder_new_post(auth, node, **kwargs):
    user = auth.user

    title = request.json.get('title')

    if not node.is_folder:
        raise HTTPError(http.BAD_REQUEST)
    folder = new_folder(strip_html(title), user)
    folders = [folder]
    try:
        _add_pointers(node, folders, auth)
    except ValueError:
        raise HTTPError(http.BAD_REQUEST)

    return {
        'projectUrl': '/dashboard/',
    }, http.CREATED
Esempio n. 5
0
def add_folder(auth, **kwargs):
    data = request.get_json()
    node_id = data.get("node_id")
    node = get_or_http_error(Node, node_id)

    user = auth.user
    title = strip_html(data.get("title"))
    if not node.is_folder:
        raise HTTPError(http.BAD_REQUEST)

    folder = new_folder(title, user)
    folders = [folder]
    try:
        _add_pointers(node, folders, auth)
    except ValueError:
        raise HTTPError(http.BAD_REQUEST)
    return {}, 201, None
Esempio n. 6
0
def add_folder(**kwargs):
    auth = kwargs['auth']
    user = auth.user
    title = strip_html(request.json.get('title'))
    node_id = request.json.get('node_id')
    node = Node.load(node_id)
    if node.is_deleted or node.is_registration or not node.is_folder:
        raise HTTPError(http.BAD_REQUEST)

    folder = new_folder(
        title, user
    )
    folders = [folder]
    try:
        _add_pointers(node, folders, auth)
    except ValueError:
        raise HTTPError(http.BAD_REQUEST)
    return {}, 201, None
Esempio n. 7
0
def folder_new_post(auth, nid, **kwargs):
    user = auth.user

    title = request.json.get('title')

    if not title or len(title) > 200:
        raise HTTPError(http.BAD_REQUEST)

    node = Node.load(nid)
    if node.is_deleted or node.is_registration or not node.is_folder:
        raise HTTPError(http.BAD_REQUEST)
    folder = new_folder(strip_html(title), user)
    folders = [folder]
    try:
        _add_pointers(node, folders, auth)
    except ValueError:
        raise HTTPError(http.BAD_REQUEST)

    return {
        'projectUrl': '/dashboard/',
    }, http.CREATED
Esempio n. 8
0
def folder_new_post(auth, nid, **kwargs):
    user = auth.user

    title = request.json.get('title')

    if not title or len(title) > 200:
        raise HTTPError(http.BAD_REQUEST)

    node = Node.load(nid)
    if node.is_deleted or node.is_registration or not node.is_folder:
        raise HTTPError(http.BAD_REQUEST)
    folder = new_folder(strip_html(title), user)
    folders = [folder]
    try:
        _add_pointers(node, folders, auth)
    except ValueError:
        raise HTTPError(http.BAD_REQUEST)

    return {
        'projectUrl': '/dashboard/',
    }, http.CREATED