From 9ac2894cb24c19afdc6ccb5319cd84a79862f6ff Mon Sep 17 00:00:00 2001 From: yusuke <67737076+yusuke-sforzando@users.noreply.github.com> Date: Fri, 20 Nov 2020 20:27:43 +0900 Subject: [PATCH 01/54] :+1: Add title and subtitle for index.html --- templates/index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/index.html b/templates/index.html index fb26863..c79c108 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,3 +1,5 @@ {% extends "_base.html" %} {% block main %} +
書籍・備品の登録
+キーワード・ISBNコード・ASINコードのいずれかを入力
{% endblock %} From 8f6cb626dbf6baa5f1b73b2ee1bc6ec55a04d9aa Mon Sep 17 00:00:00 2001 From: yusuke <67737076+yusuke-sforzando@users.noreply.github.com> Date: Fri, 20 Nov 2020 20:39:57 +0900 Subject: [PATCH 02/54] :sparkles: Add form for index.html --- .flake8 | 1 + asset.py | 26 ++++++++++++++++++++++++++ templates/index.html | 1 + 3 files changed, 28 insertions(+) create mode 100644 asset.py diff --git a/.flake8 b/.flake8 index 30ebdbb..f1dc869 100644 --- a/.flake8 +++ b/.flake8 @@ -8,3 +8,4 @@ exclude = max-line-length = 119 show-source = True statistics = True +ignore=H301 diff --git a/asset.py b/asset.py new file mode 100644 index 0000000..b3d90ed --- /dev/null +++ b/asset.py @@ -0,0 +1,26 @@ +from dataclasses import dataclass, field +from __init__ import time_now + + +@dataclass +class Asset: + + title: str + asset_id: str = field(init=False) + asin: str + url: str + images: list + manufacture: str + contributor: str + product_group: str + publication_date: str + features: str + default_position: str + current_position: str + note: str + registrant_name: str + registered_at: str = field(init=False) + + def __post_init__(self): + self.asset_id = "0" + self.registered_at = time_now diff --git a/templates/index.html b/templates/index.html index c79c108..d129ab6 100644 --- a/templates/index.html +++ b/templates/index.html @@ -2,4 +2,5 @@ {% block main %}書籍・備品の登録
キーワード・ISBNコード・ASINコードのいずれかを入力
+ {% endblock %} From 8886f239d51f9972752b4f3abda40cf658b4fb5f Mon Sep 17 00:00:00 2001 From: yusuke <67737076+yusuke-sforzando@users.noreply.github.com> Date: Fri, 20 Nov 2020 23:36:28 +0900 Subject: [PATCH 03/54] :sparkles: Improve main.py and index.html by form.get --- main.py | 10 +++++++--- templates/index.html | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 736714c..749aa53 100644 --- a/main.py +++ b/main.py @@ -1,17 +1,21 @@ # !/usr/bin/env python3 -from flask import render_template +from flask import render_template, request from __init__ import app -@app.route("/", methods=["GET"]) +@app.route("/", methods=["GET", "POST"]) def index(): app.logger.info("index(): GET /") template_filename = "index.html" + context_dict = { "subtitle": template_filename, - "message": f"This is {template_filename}." + "message": f"This is {template_filename}.", + "title": "備品・書籍の登録", + "sub_title": "キーワード、ISBNコード、ASINコードのいずれかを入力してください", + "keyword": request.form.get("input_keyword") } return render_template(template_filename, **context_dict) diff --git a/templates/index.html b/templates/index.html index d129ab6..8913296 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,6 +1,10 @@ {% extends "_base.html" %} {% block main %} -書籍・備品の登録
-キーワード・ISBNコード・ASINコードのいずれかを入力
- +{{ title }}
+{{ sub_title }}
+ +{{ keyword }}
{% endblock %} From 0eefc681e6378737e4b0d5a12453dd823024fda5 Mon Sep 17 00:00:00 2001 From: yusuke <67737076+yusuke-sforzando@users.noreply.github.com> Date: Sat, 21 Nov 2020 03:19:11 +0900 Subject: [PATCH 04/54] :sparkles: Improve main.py by session --- main.py | 20 +++++++++++++++++--- templates/search-result.html | 5 +++++ 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 templates/search-result.html diff --git a/main.py b/main.py index 749aa53..fc995d6 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,12 @@ # !/usr/bin/env python3 -from flask import render_template, request +from flask import render_template, request, session from __init__ import app +import os +app.secret_key = os.getenv("airtable_api_key") + @app.route("/", methods=["GET", "POST"]) def index(): @@ -14,11 +17,22 @@ def index(): "subtitle": template_filename, "message": f"This is {template_filename}.", "title": "備品・書籍の登録", - "sub_title": "キーワード、ISBNコード、ASINコードのいずれかを入力してください", - "keyword": request.form.get("input_keyword") + "sub_title": "キーワード、ISBNコード、ASINコードのいずれかを入力してください" } + session["keyword"] = request.form.get("input_keyword") return render_template(template_filename, **context_dict) +@ app.route("/search-result", methods=["GET"]) +def search_result(): + app.logger.info("search_result(): GET /") + template_filename = "search-result.html" + context_dict = { + "subtitle": template_filename, + "message": f"This is {template_filename}." + } + return render_template(template_filename, **context_dict, keyword=session["keyword"]) + + if __name__ == "__main__": app.run(host="0.0.0.0", port=8888) diff --git a/templates/search-result.html b/templates/search-result.html new file mode 100644 index 0000000..23a541d --- /dev/null +++ b/templates/search-result.html @@ -0,0 +1,5 @@ +{% extends "_base.html" %} +{% block main %} +{{ title }}
+{{ keyword }}
+{% endblock %} From 010545540678a5c08e9075c34fb71a8182be5cd4 Mon Sep 17 00:00:00 2001 From: yusuke <67737076+yusuke-sforzando@users.noreply.github.com> Date: Sat, 21 Nov 2020 03:20:52 +0900 Subject: [PATCH 05/54] :sparkles:Remove api key --- main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main.py b/main.py index fc995d6..ac099b0 100644 --- a/main.py +++ b/main.py @@ -4,8 +4,7 @@ from __init__ import app -import os -app.secret_key = os.getenv("airtable_api_key") +app.secret_key = "secret_key" @app.route("/", methods=["GET", "POST"]) From c1cd94ee0fa63520a601d9669c70b0400c38d861 Mon Sep 17 00:00:00 2001 From: yusuke <67737076+yusuke-sforzando@users.noreply.github.com> Date: Sat, 21 Nov 2020 03:21:29 +0900 Subject: [PATCH 06/54] :sparkles:Use app secret key --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index ac099b0..97acce4 100644 --- a/main.py +++ b/main.py @@ -4,7 +4,7 @@ from __init__ import app -app.secret_key = "secret_key" +app.secret_key = 'app secret key' @app.route("/", methods=["GET", "POST"]) From 59fdc0d94a74185cb3e570a7018ef9ac1f2a857c Mon Sep 17 00:00:00 2001 From: yusuke <67737076+yusuke-sforzando@users.noreply.github.com> Date: Sat, 21 Nov 2020 03:28:59 +0900 Subject: [PATCH 07/54] :+1: Improve secret key by app secret key --- .env.gpg | Bin 248 -> 268 bytes main.py | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.gpg b/.env.gpg index 0f4cc544157e66373bfaef553d591e2b861afaf1..14a9b04490725030f5b2a146daae9721fbe77962 100644 GIT binary patch literal 268 zcmV+n0rUQh4Fm}T0{JH3%9%?8{{ title }}
-{{ sub_title }}
- -{{ keyword }}
{% endblock %} diff --git a/templates/search-result.html b/templates/search-result.html index 23a541d..c3caef4 100644 --- a/templates/search-result.html +++ b/templates/search-result.html @@ -1,5 +1,4 @@ {% extends "_base.html" %} {% block main %} -{{ title }}
{{ keyword }}
{% endblock %} From 378c9190df720120c06bed1e845d5b58e3ec7db1 Mon Sep 17 00:00:00 2001 From: yusuke <67737076+yusuke-sforzando@users.noreply.github.com> Date: Sat, 21 Nov 2020 15:45:21 +0900 Subject: [PATCH 12/54] :memo: Remove template file name --- main.py | 5 ++--- tests/test_main.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 38c7375..0bbcdad 100644 --- a/main.py +++ b/main.py @@ -17,13 +17,12 @@ def search_result_direct_access(): return "TOPページに戻ってキーワードを入力してください" -@ app.route("/search-result", methods=["GET"]) +@app.route("/search-result", methods=["GET"]) def search_result(): app.logger.info("search_result(): GET /") - template_filename = "search-result.html" keyword = request.args.get("input_keyword", "") if keyword: - return render_template(template_filename, keyword=keyword) + return render_template("search-result.html", keyword=keyword) else: return "TOPページに戻ってキーワードを入力してください" diff --git a/tests/test_main.py b/tests/test_main.py index 1ae908e..c22cda8 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -33,6 +33,6 @@ def test_GET_search_result_query_not_inputted(test_client): def test_GET_search_result_direct_access(test_client): - response = test_client.get("/search-result") + response = test_client.get("/search-result?input_keyword=") print(response.data.decode('utf-8')) assert "TOPページに戻ってキーワードを入力してください" in response.data.decode('utf-8') From b4ae44879ce527a42513efe23133558674dcdc92 Mon Sep 17 00:00:00 2001 From: yusuke <67737076+yusuke-sforzando@users.noreply.github.com> Date: Sat, 21 Nov 2020 15:53:57 +0900 Subject: [PATCH 13/54] :memo: Rename html tag p to label --- templates/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/index.html b/templates/index.html index 7e80850..c94fc84 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,7 +1,7 @@ {% extends "_base.html" %} {% block main %}備品・書籍の登録
-キーワード、ISBNコード、ASINコードのいずれかを入力してください
+ {% endblock %} From 8cbdd477b355e145980911fe1b3fad84d9b885ef Mon Sep 17 00:00:00 2001 From: Tomoya KASHIMADA備品・書籍の登録
- - diff --git a/templates/search-result.html b/templates/search-result.html deleted file mode 100644 index c3caef4..0000000 --- a/templates/search-result.html +++ /dev/null @@ -1,4 +0,0 @@ -{% extends "_base.html" %} -{% block main %} -{{ keyword }}
-{% endblock %} diff --git a/templates/search.html b/templates/search.html new file mode 100644 index 0000000..2215ef6 --- /dev/null +++ b/templates/search.html @@ -0,0 +1,5 @@ +{% extends "_base.html" %} +{% block main %} +{{ message }}