Ejemplo n.º 1
0
    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))
        _message = self.get_argument("message", None)
        messages = []

        if _message is not None:
            messages.append(_message)

        _user_id = self.get_argument("user_id", None)
        _name = self.get_argument("name", None)

        if _user_id is not None:
            results = healthcan.user_id(_id, _user_id)
        elif _name is not None:
            results = healthcan.name(_id, _name)
        else:
            results = healthcan.select_by_user_id(_signedInUser.attr["id"])

        self.render("healthcans.html",
                    user=_signedInUser,
                    healthcans=results,
                    messages=messages,
                    user_id=_user_id,
                    name=_name,
                    errors=[])
    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))

        # 他の画面からのメッセージを取得
        _message = self.get_argument("message", None)
        messages = []
        if _message is not None: messages.append(_message)

        # 概要を取得
        _summary = self.get_argument("summary", None)

        # ユーザーごとの現金出納帳データを取得
        if _summary is not None:
            results = cashbook.summary(_id, _summary)
        else:
            results = cashbook.select_by_user_id(_signedInUser.attr["id"])
        self.render("cashbooks.html",
                    user=_signedInUser,
                    cashbooks=results,
                    messages=messages,
                    summary=_summary,
                    errors=[])
    def post(self):
        # パラメータの取得
        _fid = self.get_argument("fav", None)
        _word = self.get_argument("f-word", None)

        # ユーザーのIDを取得
        _id = tornado.escape.xhtml_escape(self.current_user)
        _uid = int(_id)
        _signedInUser = user.find(int(_id))

        # 入力された料理のidを取得
        _cid = cooking.find_nametoid(_word)

        f = favorites.build()
        if _fid == "None":
            f.attr["favorites_id"] = None
        else:
            f.attr["favorites_id"] = _fid
        f.attr["user_id"] = _uid
        f.attr["cooking_id"] = _cid
        # import pdb
        # pdb.set_trace()
        f.save()

        # ページへリダイレクト
        self.redirect("/search?form-word=" + _word)
Ejemplo n.º 4
0
    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))

        # 他の画面からのメッセージを取得
        _message = self.get_argument("message", None)
        messages = []
        if _message is not None: messages.append(_message)

        results = []

        _word = self.get_argument("word", None)
        if _word is not None:
            results = innerList.search(_id, _word)
        else:
            # ユーザーごとの現金出納帳データを取得
            results = innerList.select_by_user_id(_signedInUser.attr["id"])

        self.render("innerLists.html",
                    user=_signedInUser,
                    innerLists=results,
                    messages=messages,
                    errors=[])
        """# 概要を取得
Ejemplo n.º 5
0
    def get(self, id):  # idはURLで指定されたIDが入る
        if not self.current_user:
            self.redirect("/signin")
            return
        # サインインユーザーの取得
        _id = tornado.escape.xhtml_escape(self.current_user)
        _signedInUser = user.find(int(_id))
        # cashbookより指定されたIDでデータ取得
        cb = cashbook.find(id)
        # データが見つからない場合は404エラーを返す
        # 404エラーは、raise tornado.web.HTTPError(404) で返せます
        if (cb is None):
            raise tornado.web.HTTPError(404)

        # 取得したCashBookデータの、ユーザーIDがサインインID異なる場合も404エラーを返す
        # print(type(cb.attr['user_id']))
        # print(type(_id))
        if (cb.attr['user_id'] != int(_id)):
            raise tornado.web.HTTPError(404)

        self.render(
            "cashbook_form.html",
            user=_signedInUser,
            mode="show",  # modeはshowとする
            cashbook=cb,
            messages=[],
            errors=[])
Ejemplo n.º 6
0
    def post(self):
        # サインインユーザの取得
        _id = tornado.escape.xhtml_escape(self.current_user)
        _signedInUser = user.find(int(_id))
        # 他の画面からのメッセージを取得
        _message = self.get_argument("message", None)
        messages = []
        if _message is not None:
            messages.append(_message)
        # 概要を取得
        _favorite_id = self.get_argument("favorite", None)

        result = _signedInUser.favorite_update(_favorite_id, _id)

        if result is None:
            self.redirect("/mypageUser")
        else:
            if result == False:
                self.render("serarchResults.html",
                            user=_signedInUser,
                            artists=result,
                            messages=[],
                            errors=["できませーん"])
            else:
                self.redirect("/mypageUser?message=%s" %
                              tornado.escape.url_escape("お気に入り登録完了"))
Ejemplo n.º 7
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")
Ejemplo n.º 8
0
    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))

        self.render("cash_sort.html")
Ejemplo n.º 9
0
    def get(self):
        if not self.current_user:
            self.redirect("/signin")
            return

        _id = int(tornado.escape.xhtml_escape(self.current_user))
        _signedInUser = user.find(_id)

        self.render("dashboard.html", user=_signedInUser)
Ejemplo n.º 10
0
 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))
     # ダッシュボードを表示
     self.render("innerList.html", user=_signedInUser)
Ejemplo n.º 11
0
    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))
Ejemplo n.º 12
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_date = self.get_argument("form-date", None)
        p_summary = self.get_argument("form-summary", None)
        p_detail = self.get_argument("form-detail", None)
        p_income = self.get_argument("form-income", None)
        p_expenses = self.get_argument("form-expenses", None)

        # 現金出納帳データの組み立て
        cb = cashbook.build()
        cb.attr["user_id"] = int(_id) # ユーザーIDはサインインユーザーより取得

        # パラメータエラーチェック
        errors = []
        if p_date is None:
            errors.append("日付は必須です。")
        else:
            # 文字列をdatetime.dateオブジェクトへをキャスト
            cb.attr["date"] = datetime.datetime.strptime(p_date, '%Y-%m-%d').date()


        if p_summary is None: errors.append("摘要は必須です。")
            #(交通費)を自動で追加
        summary = "交通費" + "(" + p_summary + ")"
        cb.attr["summary"] = summary
        cb.attr["detail"] = p_detail

        if p_income is None and p_expenses is None: errors.append("収入/支出のどちらかは入力してください。")
        if p_income is None: p_income = 0
        if p_expenses is None: p_expenses = 0
        cb.attr["income"] = Decimal(p_income)
        cb.attr["expenses"] = Decimal(p_expenses)
        # 金額計算(収入 - 支出)
        cb.attr["amount"] = cb.attr["income"] - cb.attr["expenses"]

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



        # 登録
        # print(vars(cb))
        cb_id = cb.save()
        if cb_id == False:
            self.render("cashbook_formfixed.html", user=_signedInUser, mode="new", cashbook=cb, messages=[], errors=["登録時に致命的なエラーが発生しました。"])
        else:
            # 登録画面へリダイレクト(登録完了の旨を添えて)
            self.redirect("/cashbooks?message=%s" % tornado.escape.url_escape("新規登録完了しました。(ID:%s)" % cb_id))
Ejemplo n.º 13
0
    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))

        w = wishList.build()
        self.render("wishList_form.html", user=_signedInUser, mode="new", wishList=w, messages=[], errors=[])
Ejemplo n.º 14
0
    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))

        cb = cashbook.build()
        self.render("cashbookfixed_form.html", user=_signedInUser, mode="new", cashbook=cb, messages=[], errors=[])
Ejemplo n.º 15
0
    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))
        # ダッシュボードを表示
        print(_signedInUser)
        flower = cashbook.select_flower(_id)

        self.render("dashboard.html", user=_signedInUser, flower=flower)
Ejemplo n.º 16
0
 def get(self):
     if not self.current_user:
         self.redirect("/top")
         return
     # サインインユーザーの取得
     _id = tornado.escape.xhtml_escape(self.current_user)
     _signedInUser = user.find(int(_id))
     # ダッシュボードを表示
     if _signedInUser.attr["artist_name"] == None:
         self.render("mypageUser.html", user=_signedInUser)
     else:
         self.render("mypageArtist.html", user=_signedInUser)
    def get(self):
        if not self.current_user:
            self.redirect("/signin")
            return
        # サインインユーザーの取得
        _id = int(tornado.escape.xhtml_escape(self.current_user))
        _signedInUser = user.find(_id)

        # その他必要な処理をここで

        # ダッシュボードを表示
        self.render("dashboard.html", user=_signedInUser)
Ejemplo n.º 18
0
    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))
        _weight = healthcan.weight(_id)
        _bmi = healthcan.bmi(_id)
        self.render("dashboard.html",
                    user=_signedInUser,
                    weight=_weight,
                    bmi=_bmi)
Ejemplo n.º 19
0
    def get(self, id):
        if not self.current_user:
            self.redirect("/signin")
            return
        # サインインユーザーの取得
        _id = tornado.escape.xhtml_escape(self.current_user)
        _signedInUser = user.find(int(_id))

        cb = cashbook.find(id)
        if cb is None: raise tornado.web.HTTPError(404) # データが見つからない場合は404エラーを返す
        if cb.attr["user_id"] != _signedInUser.attr["id"]: raise tornado.web.HTTPError(404) # ユーザーIDが異なる場合も404エラーを返す

        self.render("cashbook_form.html", user=_signedInUser, mode="show", cashbook=cb, messages=[], errors=[])
Ejemplo n.º 20
0
    def get(self, id):
        if not self.current_user:
            self.redirect("/signin")
            return
        # サインインユーザーの取得
        _id = tornado.escape.xhtml_escape(self.current_user)
        _signedInUser = user.find(int(_id))

        w = wishList.find(id)
        if w is None: raise tornado.web.HTTPError(404) # データが見つからない場合は404エラーを返す
        if w.attr["user_id"] != _signedInUser.attr["id"]: raise tornado.web.HTTPError(404) # ユーザーIDが異なる場合も404エラーを返す

        self.render("wishList_form.html", user=_signedInUser, mode="edit", wishList=w, messages=[], errors=[])
Ejemplo n.º 21
0
    def get(self, id):
        if not self.current_user:
            self.redirect("/signin")
            return
        # サインインユーザーの取得
        _id = tornado.escape.xhtml_escape(self.current_user)
        _signedInUser = user.find(int(_id))

        cb = cashbook.find(id)
        if cb is None: raise tornado.web.HTTPError(404) # データが見つからない場合は404エラーを返す
        if cb.attr["user_id"] != _signedInUser.attr["id"]: raise tornado.web.HTTPError(404) # ユーザーIDが異なる場合も404エラーを返す

        cb.delete()

        self.redirect("/cashbooks")
Ejemplo n.º 22
0
    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))
        hc = healthcan.build()

        self.render("healthcan_form.html",
                    user=_signedInUser,
                    mode="new",
                    healthcan=hc,
                    messages=[],
                    errors=[])
Ejemplo n.º 23
0
    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))

        with DBConnector(dbName='db_%s' % project.name()) as con, con.cursor(MySQLdb.cursors.DictCursor) as cursor:
            cursor.execute("""
                SELECT
                    *
                FROM
                    table_cashbook
                ORDER BY
                    id;
            """)
            results = cursor.fetchall()
        if (len(results) == 0):
            print(None)
            return None

        cash_attrs = [
            "id",
            "user_id",
            "ym",
            # "data",
            # "summary",
            # "detail",
            # "income",
            # "expenses",
            # "amount",
            # "last_updated"
        ]
        response = {}

        self.write("[".encode())
        for data in results:
            for attr in cash_attrs:
                if(attr == "data"):
                    response["%s" % attr] = str(data["%s" % attr])
                else:
                    response["%s" % attr] = data["%s" % attr]
            self.set_header("Content-Type", "application/json; charset=UTF-8")
            self.write(json.dumps(response))
            if(results[-1] != data):
                self.write(','.encode())
        self.write("]".encode())
Ejemplo n.º 24
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("innerlist_id", None)

        il = innerList.find(p_id)

        il.delete()

        self.redirect("/")
    def get(self):
        _id = tornado.escape.xhtml_escape(self.current_user)
        _uid = int(_id)
        _signedInUser = user.find(int(_id))

        _word = self.get_argument("form-word", None)

        # ingredient.pyからingredient_idを取得
        ingredient_id = ingredient.find_nametoingredient_id(_word)
        # amount.pyからingredient_idを使いcooking_idを取得
        cooking_ids = amount.find_ingredient_idtocooking_id(ingredient_id)
        _cooking_names = [cooking.find_idtoname(coo) for coo in cooking_ids]

        _favorites = favorites.find_favorite(_uid)

        self.render("search.html", user=_signedInUser)
Ejemplo n.º 26
0
    def get(self, id):
        if not self.current_user:
            self.redirect("/signin")
            return

        _id = tornado.escape.xhtml_escape(self.current_user)
        _signedInUser = user.find(int(_id))
        hc = healthcan.find(id)

        if hc is None:
            raise tornado.web.HTTPError(404)
        if hc.attr["user_id"] != _signedInUser.attr["id"]:
            raise tornado.web.HTTPError(404)

        self.render("healthcan_form.html",
                    user=_signedInUser,
                    mode="show",
                    healthcan=hc,
                    messages=[],
                    errors=[])
Ejemplo n.º 27
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_name = self.get_argument("form-name", None)
        p_quantity = self.get_argument("form-quantity", None)
        p_kind = self.get_argument("form-kind", None)
        #p_last_updated = self.get_argument("form-last_updated", None)

        # 現金出納帳データの組み立て
        w = wishList.build()
        w.attr["user_id"] = int(_id) # ユーザーIDはサインインユーザーより取得

        errors = []
        if p_name is None: errors.append("品名は必須です。")
        w.attr["name"] = p_name

        w.attr["quantity"] = p_quantity

        w.attr["kind"] = p_kind

        #w.attr["last_updated"] = p_last_updated

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

        # 登録
        # print(vars(w))
        w_id = w.save()
        if w_id == False:
            self.render("wishList_form.html", user=_signedInUser, mode="new", wishList=w, messages=[], errors=["登録時に致命的なエラーが発生しました。"])
        else:
            # 登録画面へリダイレクト(登録完了の旨を添えて)
            self.redirect("/wishlist?message=%s" % tornado.escape.url_escape("新規登録完了しました。(ID:%s)" % w_id))
Ejemplo n.º 28
0
    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))

        with DBConnector(dbName='db_%s' % project.name()) as con, con.cursor(
                MySQLdb.cursors.DictCursor) as cursor:
            cursor.execute(
                """
                SELECT
                    summary
                ,   SUM(expenses) AS sum_expenses
                FROM
                    table_cashbook
                WHERE
                    user_id = %s
                AND expenses != 0
                GROUP BY
                    summary
                ORDER BY
                    sum_expenses DESC;
            """, (int(_id), ))
            results = cursor.fetchall()

        if (len(results) == 0):
            return None

        response = {}
        response["labels"] = []
        response["values"] = []
        for data in results:
            response["labels"].append(data["summary"])
            response["values"].append(str(data["sum_expenses"]))

        self.set_header("Content-Type", "application/json; charset=UTF-8")
        self.write(json.dumps(response))
    def get(self):
        _id = tornado.escape.xhtml_escape(self.current_user)
        _uid = int(_id)
        _signedInUser = user.find(int(_id))

        # ユーザーIDによるお気に入り情報の取得
        _favorites = favorites.find_favorite(_uid)
        _cooking_names = [
            cooking.find_idtoname(fav["cooking_id"]) for fav in _favorites
        ]

        # favorites_IDを取得
        # _favorite = [fav["favorites_id"] for fav in _favorites]

        # if len(_favorite) == 0:
        #     _favorite = None
        # else:
        #     _favorite = _favorite

        self.render("profile.html",
                    user=_signedInUser,
                    favorites=_favorites,
                    cooking_names=_cooking_names)
Ejemplo n.º 30
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))

        p_summary = self.get_argument("summary", None)
        p_date = self.get_argument("year", None) + self.get_argument("month", None)
        print(self.get_argument("summary", None))

        if p_summary is not "" and p_date is not "":
            self.redirect("/cashbooks?summary=%s&date=%s" % (p_summary, p_date,))

        if p_summary is not "":
            self.redirect("/cashbooks?summary=%s" % p_summary)
            return

        if p_date is not "":
            self.redirect("/cashbooks?date=%s" % p_date)
            return

        self.redirect('/cashbooks')