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')
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')
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')
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')