Example #1
0
def show_node(num, name):
    """
    Renders a page given it's entry id
    """
    entry = None
    url = None
    editors = None
    if num < 0 and name:
        entry_db = EntryDB()
        try:
            entry = entry_db.find_by_URL(name)[0]
        except:
            abort(404)
    else:
        entry_db = EntryDB()
        entry = entry_db.find_by_id(num)
    if entry == None and url == None:
        abort(404)

    children = []
    try:
        if entry is not None:
            es = entry_db.find_editors_by_entry(entry.id)
            if len(es) > 0:
                editors = es

            if entry.children:
                children.append(entry)
                children.extend(sorted(entry.children, key=lambda e: e.weight))
            elif entry.parent_id is not None:
                te = entry_db.find_by_id(entry.parent_id)
                children.append(te)
                children.extend(sorted(te.children, key=lambda e: e.weight))
    except:
        editors = None

    #import ipdb; ipdb.set_trace()
    return render_template('node.html', entry=entry, editors=editors,
        state=get_state(), children=children)
Example #2
0
def process_entry_object(parent):
    '''
    Return an entry object. Does not add to db
    '''
    user_db = UserDB()
    entry_db = EntryDB()
    group_used = user_db.get_group(request.form.get('group', None))
    purl = request.form.get('url', None)
    if purl is not None:
        t = entry_db.find_by_URL(purl)
        if len(t) > 0:
            flash(_("'{0}' URL is already in use!".format(purl)))
            purl = None
    return entry_db.create_temp_entry(
        request.form.get('title', ''),
        request.form.get('entry', ''),
        current_user,
        group_used,
        int(request.form.get('weight', 0)),
        purl,
        bool(request.form.get('html', False)),
        parent,
        bool(request.form.get('static', False)))