Ejemplo n.º 1
0
def delete_tag(request):
    """todo: actually delete tags
    now it is only deletion of category from the tree"""
    if request.user.is_anonymous() or not request.user.is_administrator_or_moderator():
        raise exceptions.PermissionDenied()
    post_data = simplejson.loads(request.raw_post_data)
    tag_name = forms.clean_tag(post_data["tag_name"])
    path = post_data["path"]
    tree = category_tree.get_data()
    category_tree.delete_category(tree, tag_name, path)
    category_tree.save_data(tree)
    return {"tree_data": tree}
Ejemplo n.º 2
0
def delete_tag(request):
    """todo: actually delete tags
    now it is only deletion of category from the tree"""
    if request.user.is_anonymous() or not request.user.is_administrator_or_moderator():
        raise exceptions.PermissionDenied()

    try:
        post_data = simplejson.loads(request.body)
        tag_name = post_data["tag_name"]
        path = post_data["path"]
        tree = category_tree.get_data()
        category_tree.delete_category(tree, tag_name, path)
        category_tree.save_data(tree)
    except Exception:
        if "tag_name" in locals():
            logging.critical("could not delete tag %s" % tag_name)
        else:
            logging.critical("failed to parse post data %s" % request.body)
        raise exceptions.PermissionDenied(_("Sorry, could not delete tag"))
    return {"tree_data": tree}
Ejemplo n.º 3
0
def delete_tag(request):
    """TODO: actually delete tags
    now it is only deletion of category from the tree"""
    if request.user.is_anonymous() \
        or not request.user.is_administrator_or_moderator():
        raise exceptions.PermissionDenied()

    try:
        post_data = json.loads(request.raw_post_data)
        tag_name = post_data['tag_name']
        path = post_data['path']
        tree = category_tree.get_data()
        category_tree.delete_category(tree, tag_name, path)
        category_tree.save_data(tree)
    except Exception:
        traceback.print_exc()
        if 'tag_name' in locals():
            logging.critical('could not delete tag %s' % tag_name)
        else:
            logging.critical('failed to parse post data %s' % request.raw_post_data)
        raise exceptions.PermissionDenied(_('Sorry, could not delete tag'))
    return {'tree_data': tree}
Ejemplo n.º 4
0
def delete_tag(request):
    """TODO: actually delete tags
    now it is only deletion of category from the tree"""
    if request.user.is_anonymous() \
        or not request.user.is_administrator_or_moderator():
        raise exceptions.PermissionDenied()

    try:
        post_data = json.loads(request.raw_post_data)
        tag_name = post_data['tag_name']
        path = post_data['path']
        tree = category_tree.get_data()
        category_tree.delete_category(tree, tag_name, path)
        category_tree.save_data(tree)
    except Exception:
        traceback.print_exc()
        if 'tag_name' in locals():
            logging.critical('could not delete tag %s' % tag_name)
        else:
            logging.critical('failed to parse post data %s' %
                             request.raw_post_data)
        raise exceptions.PermissionDenied(_('Sorry, could not delete tag'))
    return {'tree_data': tree}