Beispiel #1
0
    def post(self):
        if not self.current_user:
            self.redirect("/signin")
            return
        # サインインユーザーの取得
        _id = tornado.escape.xhtml_escape(self.current_user)
        _signedInUser = user.find(int(_id))

        # POSTされたパラメータを取得
        p_id = self.get_argument("wishlist_id", None)

        w = wishList.move(p_id)

        il = innerList.build()

        il.attr["user_id"] = w.attr["user_id"]  # ユーザーIDはサインインユーザーより取得

        il.attr["product_name"] = w.attr["name"]

        il.attr["kind"] = w.attr["kind"]

        il.attr["amount"] = w.attr["quantity"]

        il.attr["whose"] = ""
        il.attr["lim"] = ""

        il.save()

        self.redirect("/wishlist")
    def post(self, id):
        if not self.current_user:
            self.redirect("/signin")
            return
        # サインインユーザーの取得
        _id = tornado.escape.xhtml_escape(self.current_user)
        _signedInUser = user.find(int(_id))

        # POSTされたパラメータを取得
        p_product_name = self.get_argument("form-product_name", None)
        p_lim = self.get_argument("form-lim", None)
        p_amount = self.get_argument("form-amount", None)
        p_whose = self.get_argument("form-whose", None)
        p_kind = self.get_argument("form-kind", None)

        # 現金出納帳データの組み立て
        il = innerList.build()
        il.attr["user_id"] = int(_id)  # ユーザーIDはサインインユーザーより取得
        il.attr["id"] = id
        errors = []
        if p_product_name is None: errors.append("品名は必須です。")
        il.attr["product_name"] = p_product_name

        il.attr["lim"] = p_lim

        il.attr["whose"] = p_whose

        il.attr["kind"] = p_kind

        il.attr["amount"] = p_amount
        #il.attr["last_updated"] = p_last_updated

        if len(errors) > 0:  # エラーは新規登録画面に渡す
            self.render("innerList_form.html",
                        user=_signedInUser,
                        mode="new",
                        innerList=il,
                        messages=[],
                        errors=[])
            return

        # 登録
        # print(vars(w))
        il_id = il.save()
        if il_id == False:
            self.render("innerList_form.html",
                        user=_signedInUser,
                        mode="new",
                        innerList=il,
                        messages=[],
                        errors=["登録時に致命的なエラーが発生しました。"])
        else:
            # 登録画面へリダイレクト(登録完了の旨を添えて)
            self.redirect(
                "/?message=%s" %
                tornado.escape.url_escape("変更を完了しました。(ID:%s)" % il_id))
Beispiel #3
0
 def setUp(self):
     self.i = innerList.build()
     self.i.attr["user_id"] = 1
     self.i.attr["product_name"] = "tofu"
     self.i.attr["lim"] = 20201011
     self.i.attr["amount"] = 1
     self.i.attr["whose"] = "me"
     self.i.attr["kind"] = "newseihin"
     innerList.migrate()
     self.i.save()
Beispiel #4
0
 def test_save_INSERT(self):
     i = innerList.build()
     i.attr["user_id"] = 1
     i.attr["product_name"] = "tofu"
     i.attr["lim"] = 20201011
     i.attr["amount"] = 1
     i.attr["whose"] = "me"
     i.attr["kind"] = "newseihin"
     result = i.save()
     self.assertTrue(type(result) is int)
     self.assertTrue(i.attr["id"] is not None)
    def get(self):
        if not self.current_user:
            self.redirect("/signin")
            return
        # サインインユーザーの取得
        _id = tornado.escape.xhtml_escape(self.current_user)
        _signedInUser = user.find(int(_id))

        il = innerList.build()
        self.render("innerList_form.html",
                    user=_signedInUser,
                    mode="new",
                    innerList=il,
                    messages=[],
                    errors=[])
Beispiel #6
0
 def test_build(self):
     i = innerList.build()
     self.assertTrue(type(i) is innerList)