示例#1
0
文件: tags.py 项目: oamike/scarfage
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
文件: items.py 项目: cmazuc/scarfage
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
文件: tags.py 项目: oamike/scarfage
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
文件: tags.py 项目: oamike/scarfage
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
文件: tags.py 项目: oamike/scarfage
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')