예제 #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 post_update_kit(kit_id):
    form = UpdateForm(csrf_enabled=False)
    form.init()
    form.process(request.form)
    kit_file = request.files["kit_file"]

    if form.validate():
        json = {
            "request": {
                "substance": {
                    "kit_id": form.kit_id.data,
                    "kit_name": form.kit_name.data,
                    "category_id": form.category_id.data,
                    "tags": unicode(form.tags.data).split(","),
                    "description": form.description.data,
                    "kit_file": kit_file,
                    "valid": True if form.valid.data == "True" else False,
                }
            }
        }
        req = json.get("request")
        ret = KitFacade.update(req, secure=False).get("response")
        if ret and ret.get("result") == const.RESPONSE_RESULT_SUCCESSFUL:
            return redirect("/admin/author/update/" + form.author_id.data)
        else:
            form.errors["exceptions"] = [ret.get("message")]
    return render_template("kit/update.html", form=form)
예제 #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 get_update_kit(kit_id):
    form = UpdateForm(csrf_enabled=False)
    form.init()
    json = {
        "request": {
            "substance": {
                "kit_id": kit_id,
            }
        }
    }
    req = json.get("request")
    ret = KitFacade.read(req).get("response")
    if ret and ret.get("result") == const.RESPONSE_RESULT_SUCCESSFUL:
        substance = ret.get("substance")

        form.kit_id.data = substance.get("kit_id")
        form.kit_name.data = substance.get("kit_name")
        form.author_id.data = substance.get("author").get("author_id")
        form.category_id.data = substance.get("category").get("category_id")
        form.tags.data = ",".join(substance.get("tags"))
        form.description.data = substance.get("description")
        form.valid.data = str(substance.get("valid"))
    else:
        return redirect("/admin/author/list")
    return render_template("kit/update.html", form=form)
예제 #6
0
def read_kit(kit_id):
    json = {
        "request": {
            "substance": {
                "kit_id": kit_id,
            }
        }
    }
    req = json.get("request")
    res = KitFacade.read(req)
    return jsonify(res)
예제 #7
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)
예제 #8
0
def download_kit(kit_id):
    json = {
        "request": {
            "substance": {
                "kit_id": kit_id,
            }
        }
    }
    req = json.get("request")
    ret = KitFacade.download(req).get("response")
    if ret and ret.get("result") == const.RESPONSE_RESULT_SUCCESSFUL:
        substance = ret.get("substance")
        kit_file = substance.get("kit_file")
        return send_file(filename_or_fp=kit_file, attachment_filename=kit_file.blob_info.filename, as_attachment=True)
    else:
        abort(404)
예제 #9
0
def create_kit():
    json = {
        "request": {
            "credential": {
                "author_id": "a2e006bc0d489746ee6ac9415da7ef352091bbe8",
                "token": "b941295b36824f0fc19cc473ba9d6b67866b2709"
            },
            "substance": {
                "author_id": "a2e006bc0d489746ee6ac9415da7ef352091bbe8",
                "kit_name": u"My Wonderful Kit",
                "category_id": "253b16bf5d78bd4bb3af19ed874c4468e759f2d0",
                "tags": ["render", "camera"],
                "description": u"これはmodoの素晴らしいキットです。\nみなさんぜひご利用ください。",
            }
        }

    }
    req = json.get("request")
    res = KitFacade.create(req)
    return jsonify(res)
예제 #10
0
def update_kit():
    json = {
        "request": {
            "credential": {
                "author_id": "a2e006bc0d489746ee6ac9415da7ef352091bbe8",
                "token": "b941295b36824f0fc19cc473ba9d6b67866b2709"
            },
            "substance": {
                "kit_id": "3b1efa98eac78dd9a887b949c07bc739fcd2d044",
                "kit_name": u"My Wonderful Kit Review!",
                "category_id": "c1ac4c51afdd9ed6df0d3d871d38f261b70dcba8",
                "tags": [u"geo"],
                "description": u"これはmodoの素晴らしいキットです。\nみなさんぜひご利用ください。\n内容を改変しました。",
                "valid": True,
            }
        }
    }

    req = json.get("request")
    res = KitFacade.update(req)
    return jsonify(res)
예제 #11
0
def list_kit():
    res = KitFacade.list(request.json)
    return jsonify(res)