示例#1
0
文件: views.py 项目: 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')
示例#2
0
文件: views.py 项目: 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')
示例#3
0
文件: views.py 项目: 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')
示例#4
0
文件: views.py 项目: 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')