Exemplo n.º 1
0
def push_add(account_dir, box_dir):
    title = request.form["title"]
    desc = request.form["desc"]
    re = biz.box_usable(account_dir, box_dir)
    if re.errcode == model.HAVEDIR:

        try:
            re = biz.box_biz.box_user_level(account_dir, box_dir, session["dir"])
            if re.errcode != model.OK:
                lev = 0
            else:
                lev = re.data
        except KeyError:
            lev = 0

        if lev == 3:
            user_id = biz.get_id_by_dir(session["dir"])

            box = biz.box_biz.get_box(account_dir, box_dir)

            push = model.Push(box.data.id, user_id.data, title, desc)

            biz.push_biz.add_push(push)

            return redirect(url_for("push_view", account_dir=account_dir, box_dir=box_dir))
    else:
        return render_template(config.VIEW + "/404.html")