示例#1
0
def post_update_author(author_id):
    form = UpdateForm(request.form, csrf_enabled=False)
    if form.validate():
        json = {
            "request": {
                "substance": {
                    "author_id": form.author_id.data,
                    "author_name": form.author_name.data,
                    "mail_address": form.mail_address.data,
                    "valid": True if form.valid.data == "True" else False,
                }
            }
        }
        req = json.get("request")
        ret = AuthorFacade.update(req, secure=False).get("response")
        if ret and ret.get("result") == const.RESPONSE_RESULT_SUCCESSFUL:
            return redirect("/admin/author/list")
        else:
            form.errors["exceptions"] = [ret.get("message")]

    json = {
        "request": {
            "substance": {
                "author_id": author_id
            }
        }
    }
    req = json.get("request")
    res = KitFacade.list(req)
    kits = res.get("response").get("substance").get("items")
    return render_template("author/update.html", form=form, kits=kits)
示例#2
0
def update_author(author_id):
    form = UpdateForm(csrf_enabled=False)
    json = {
        "request": {
            "substance": {
                "author_id": author_id,
            }
        }
    }
    req = json.get("request")
    ret = AuthorFacade.read(req).get("response")
    if ret and ret.get("result") == const.RESPONSE_RESULT_SUCCESSFUL:
        substance = ret.get("substance")

        form.author_id.data = substance.get("author_id")
        form.author_name.data = substance.get("author_name")
        form.mail_address.data = substance.get("mail_address")
        form.valid.data = str(substance.get("valid"))
    else:
        return redirect("/admin/author/create")

    json = {
        "request": {
            "substance": {
                "author_id": author_id
            }
        }
    }
    req = json.get("request")
    res = KitFacade.list(req)
    kits = res.get("response").get("substance").get("items")
    return render_template("author/update.html", form=form, kits=kits)
示例#3
0
def get_update_password_author(author_id):
    json = {
        "request": {
            "substance": {
                "author_id": author_id,
            }
        }
    }
    req = json.get("request")
    ret = AuthorFacade.read(req).get("response")
    if not ret or ret.get("result") != const.RESPONSE_RESULT_SUCCESSFUL:
        return redirect("/admin/author/create")

    form = UpdatePasswordForm(csrf_enabled=False)
    form.author_id.data = author_id

    json = {
        "request": {
            "substance": {
                "author_id": author_id
            }
        }
    }
    req = json.get("request")
    res = KitFacade.list(req)
    kits = res.get("response").get("substance").get("items")
    return render_template("author/update_password.html", form=form, kits=kits)
示例#4
0
def list_kit():
    json = {
        "request": {
            "substance": {
            }
        }
    }
    req = json.get("request")
    res = KitFacade.list(req)
    kits = res.get("response").get("substance").get("items")
    return render_template("kit/list.html", kits=kits)
示例#5
0
def list_kit():
    res = KitFacade.list(request.json)
    return jsonify(res)