Пример #1
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)
Пример #2
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)
Пример #3
0
def create_author():
    json = {
        "request": {
            "substance": {
                "author_name": u"Masahiro Atsumi",
                "mail_address": "*****@*****.**",
                "password": "******"
            }
        }
    }
    #    json = {
    #        "request": {
    #            "credential": {
    #                "author_id": "*****@*****.**",
    #                "token": "1234567890abcde",
    #                },
    #            "substance": {
    #                "author_name": u"渥美政廣",
    #                "mail_address": "*****@*****.**",
    #                "password": "******"
    #            }
    #        }
    #    }

    req = json.get("request")
    res = AuthorFacade.create(req)
    return jsonify(res)
Пример #4
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)
Пример #5
0
def read_author():
    json = {
        "request": {
            "substance": {
                "author_id": "a2e006bc0d489746ee6ac9415da7ef352091bbe8",
                }
        }
    }

    req = json.get("request")
    res = AuthorFacade.read(req)
    return jsonify(res)
Пример #6
0
def authentication_author():
    json = {
        "request": {
            "substance": {
                "author_id": "a2e006bc0d489746ee6ac9415da7ef352091bbe8",
                "password": "******"
            }
        }
    }

    req = json.get("request")
    res = AuthorFacade.authentication(req)
    return jsonify(res)
Пример #7
0
def update_password_author():
    json = {
        "request": {
            "credential": {
                "author_id": "a2e006bc0d489746ee6ac9415da7ef352091bbe8",
                "token": "b941295b36824f0fc19cc473ba9d6b67866b2709"
            },
            "substance": {
                "author_id": "a2e006bc0d489746ee6ac9415da7ef352091bbe8",
                "password": "******"
            }
        }
    }

    req = json.get("request")
    res = AuthorFacade.update_password(req)
    return jsonify(res)
Пример #8
0
def post_create_author():
    form = CreateForm(request.form, csrf_enabled=False)
    if form.validate():
        json = {
            "request": {
                "substance": {
                    "author_name": form.author_name.data,
                    "mail_address": form.mail_address.data,
                    "password": form.password.data,
                }
            }
        }
        req = json.get("request")
        ret = AuthorFacade.create(req).get("response")
        if ret and ret.get("result") == const.RESPONSE_RESULT_SUCCESSFUL:
            return redirect("/admin/author/list")
        else:
            form.errors["exceptions"] = [ret.get("message")]
    return render_template("author/create.html", form=form)
Пример #9
0
def update_author():
    json = {
        "request": {
            "credential": {
                "author_id": "a2e006bc0d489746ee6ac9415da7ef352091bbe8",
                "token": "b941295b36824f0fc19cc473ba9d6b67866b2709"
            },
            "substance": {
                "author_id": "a2e006bc0d489746ee6ac9415da7ef352091bbe8",
                "author_name": u"Masahiro Atsumi desu!",
                "mail_address": "*****@*****.**",
                "valid": True,
                }
        }
    }

    req = json.get("request")
    res = AuthorFacade.update(req)
    return jsonify(res)
Пример #10
0
def list_author():
    res = AuthorFacade.list()
    authors = res.get("response").get("substance").get("items")
    return render_template("author/list.html", authors=authors)
Пример #11
0
def list_author():
    res = AuthorFacade.list()
    return jsonify(res)