Esempio n. 1
0
def retrieveParents(item_id):
    item_id = ObjectId(item_id)
    need = {
        "parent_items": True,
        "parent_rels": True
    }
    parents = db.getItemInfo(item_id, need, True)
    if parents is None:
        return 'This item does not exist'
    return jsonify(parents)
Esempio n. 2
0
def retrieveChildren(item_id):
    item_id = ObjectId(item_id)
    need = {
        "child_items": True,
        "child_rels": True
    }
    children = db.getItemInfo(item_id, need, True)
    if children is None:
        return 'This item does not exist'
    return jsonify(children)
Esempio n. 3
0
File: views.py Progetto: yedi/Avalon
def viewItem(item_id):
    item_id = ObjectId(item_id)
    if db.getItem(item_id) is None:
        return 'This item does not exist'
    session['current_item'] = item_id
    need = {"parent_items": True, "child_items": True, "child_rels": True}
    item_info = db.getItemInfo(item_id, need, True)
    item_info['comment_rels'] = db.getCommentRels(item_id)
    item_info['comment_items'] = db.prepareForClient(
        [db.getItem(rel['child']) for rel in item_info['comment_rels']])
    item_info['comment_rels'] = db.prepareForClient(item_info['comment_rels'])

    if session['logged_in']:
        db.markSeen(session['username'], item_id, True)

    return render_template('view.html', ii=item_info, tab='view-tab')
Esempio n. 4
0
File: views.py Progetto: yedi/Avalon
def item_page(item_id, initial_items=[], initial_rels=[]):
    item_id = ObjectId(item_id)
    if db.getItem(item_id) is None:
        return 'This item does not exist'
    session['current_item'] = item_id
    need = {"parent_items": True, "child_items": True, "child_rels": True}
    node_dict = db.getItemInfo(item_id, need, True)
    node_dict.update({
        "initial_items": initial_items,
        "initial_rels": initial_rels
    })
    # node_dict['users'][:] = [d['name'] for d in node_dict['users']]

    if session['logged_in']:
        db.markSeen(session['username'], item_id)

    # return render_template('page.html', nd=node_dict, tab='browse-tab')
    return render_template('page-bb.html', nd=node_dict, tab='browse-tab')
Esempio n. 5
0
File: views.py Progetto: yedi/Avalon
def viewItem(item_id):
    item_id = ObjectId(item_id)
    if db.getItem(item_id) is None:
        return 'This item does not exist'
    session['current_item'] = item_id
    need = {
        "parent_items": True,
        "child_items": True,
        "child_rels": True
    }
    item_info = db.getItemInfo(item_id, need, True)
    item_info['comment_rels'] = db.getCommentRels(item_id)
    item_info['comment_items'] = db.prepareForClient([db.getItem(rel['child']) for rel in item_info['comment_rels']])
    item_info['comment_rels'] = db.prepareForClient(item_info['comment_rels'])

    if session['logged_in']:
        db.markSeen(session['username'], item_id, True)

    return render_template('view.html', ii=item_info, tab='view-tab')
Esempio n. 6
0
File: views.py Progetto: yedi/Avalon
def item_page(item_id, initial_items=[], initial_rels=[]):
    item_id = ObjectId(item_id)
    if db.getItem(item_id) is None:
        return 'This item does not exist'
    session['current_item'] = item_id
    need = {
        "parent_items": True,
        "child_items": True,
        "child_rels": True
    }
    node_dict = db.getItemInfo(item_id, need, True)
    node_dict.update({
        "initial_items": initial_items,
        "initial_rels": initial_rels
    })
    # node_dict['users'][:] = [d['name'] for d in node_dict['users']]

    if session['logged_in']:
        db.markSeen(session['username'], item_id)

    # return render_template('page.html', nd=node_dict, tab='browse-tab')
    return render_template('page-bb.html', nd=node_dict, tab='browse-tab')