Пример #1
0
def tagreparent():
    pd = PageData()

    if request.method == 'POST':
        if 'username' in session:
            userid = pd.authuser.uid
        else:
            userid = 0 

        if 'reparent' in request.form:
            try:
                Tags().reparent(pd.decode(request.form['name']), pd.decode(request.form['reparent']))
            except IndexError:
                flash('Error reparenting tag!')

    return redirect_back('index')
Пример #2
0
def tagreparent():
    pd = PageData()

    if request.method == 'POST':
        if 'username' in session:
            userid = pd.authuser.uid
        else:
            userid = 0 

        if 'reparent' in request.form:
            try:
                Tags().reparent(pd.decode(request.form['name']), pd.decode(request.form['reparent']))
            except IndexError:
                flash('Error reparenting tag!')

    return redirect_back('index')
Пример #3
0
def untag_item(item_id, tag_ob):
    try:
        item = SiteItem.create(item_id)
    except NoItem:
        return page_not_found()

    pd = PageData()
    item.remove_tag(pd.decode(tag_ob))
    return redirect('/item/' + str(item.uid))
Пример #4
0
def untag_item(item_id, tag_ob):
    try:
        item = SiteItem.create(item_id)
    except NoItem: 
        return page_not_found()

    pd = PageData()
    item.remove_tag(pd.decode(tag_ob))
    return redirect('/item/' + str(item.uid))
Пример #5
0
def mod_tag_delete(tag):
    pd = PageData()

    tree = Tags()
    decode_tag = pd.decode(tag)
    parent = tree.parent_of(decode_tag)

    if tree.delete(decode_tag):
        return redirect('/tag/' + pd.encode(parent))
    else:
        flash('Unable to delete tag: ' + decode_tag)
        return redirect_back('/tag/' + tag)
Пример #6
0
def mod_tag_delete(tag):
    pd = PageData()

    tree = Tags()
    decode_tag = pd.decode(tag)
    parent = tree.parent_of(decode_tag)

    if tree.delete(decode_tag):
        return redirect('/tag/' + pd.encode(parent))
    else:
        flash('Unable to delete tag: ' + decode_tag)
        return redirect_back('/tag/' + tag)
Пример #7
0
def mod_tag(tag):
    pd = PageData()

    pd.tree = Tags()
    try:
        pd.tag = pd.decode(tag)

        all_tags = pd.tree.all_children_of(pd.tree.root)

        # remove children and ourself from the reparent list
        subtract = pd.tree.all_children_of(pd.tag)
        subtract.append(pd.tag)
        pd.reparent_list = list(set(all_tags) ^ set(subtract))

        pd.root_tree = pd.tree.draw_tree(pd.tree.root)

        return render_template('tag.html', pd=pd)
    except TypeError:
        return page_not_found(404)
Пример #8
0
def mod_tag(tag):
    pd = PageData()

    pd.tree = Tags()
    try:
        pd.tag = pd.decode(tag)

        all_tags = pd.tree.all_children_of(pd.tree.root)

        # remove children and ourself from the reparent list
        subtract = pd.tree.all_children_of(pd.tag)
        subtract.append(pd.tag)
        pd.reparent_list = list(set(all_tags) ^ set(subtract))

        pd.root_tree = pd.tree.draw_tree(pd.tree.root)

        return render_template('tag.html', pd=pd)
    except TypeError:
        return page_not_found()
Пример #9
0
def newtag():
    pd = PageData()

    if request.method == 'POST':
        if 'username' in session:
            userid = pd.authuser.uid
        else:
            userid = 0 

        if 'tag' in request.form:

            if request.form['tag'] == '':
                return redirect_back('index')

            try:
                Tags().retrieve(request.form['tag'].strip())
                flash('Tag already exists!')
            except IndexError:
                Tags().insert_children([request.form['tag']], pd.decode(request.form['parent']))

    return redirect_back('index')
Пример #10
0
def newtag():
    pd = PageData()

    if request.method == 'POST':
        if 'username' in session:
            userid = pd.authuser.uid
        else:
            userid = 0 

        if 'tag' in request.form:

            if request.form['tag'] == '':
                return redirect_back('index')

            try:
                Tags().retrieve(request.form['tag'].strip())
                flash('Tag already exists!')
            except IndexError:
                Tags().insert_children([request.form['tag']], pd.decode(request.form['parent']))

    return redirect_back('index')