-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
Codecov Report
@@ Coverage Diff @@
## main #26 +/- ##
==========================================
+ Coverage 79.01% 80.89% +1.88%
==========================================
Files 4 4
Lines 81 89 +8
Branches 6 7 +1
==========================================
+ Hits 64 72 +8
Misses 12 12
Partials 5 5
Continue to review full report at Codecov.
|
main.py
Outdated
app.logger.info("search_result(): GET /") | ||
keyword = request.args.get("input_keyword", "") | ||
if keyword: | ||
return render_template("search-result.html", keyword=keyword) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
元あった context_dict
を活かして、keyword
を追加する方が良いかな。
なぜなら、この後context_dict
には、Amazon PA-APIで取得した結果とか、default_positionsとかそう言うのが追加されていくことが想定できるから。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
確かにそうですね。
修正します。
失礼しました。 |
{% extends "_base.html" %} | ||
{% block main %} | ||
<h1>Search Result</h1> | ||
<h2>Keyword: {{ keyword }}</h2> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flash messageを実装したらそもそもTopページにリダイレクトさせてからのメッセージ表示とかにできたらと思っているのだけど、
現時点では、messageが表示される = Keyword がない というない状況で、keyword:
と表示されているのは変だから、
{% if not message %}
<h2>Keyword: {{ keyword }}</h2>
{% endif %}
の場合分けをするのはどうでしょうか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そうですね。その方が良いですね。
修正します。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
いや、むしろ index.html
に戻してあげなよ。message付きで。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なるほどですね。
そうですね、そちらの方がユーザーファーストなのでそちらでやってみます。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index.html
がレンダーされた、と言うテストが必要なのでは?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こちらもそうですね。
追記します。
main.py
Outdated
"message": "This is dummy message." | ||
"subtitle": f"Search Result for {keyword}", | ||
"keyword": keyword, | ||
"message": None if keyword else "Enter keywords back on the top page." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index.html
で表示されるメッセージなら、文章としては、"Enter any keywords."
で良さそうですね
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そうですね。
修正します。
main.py
Outdated
|
||
from __init__ import app | ||
|
||
app.secret_key = "aasss" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このPRでは、不要と思います。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そうですね、修正します。
if keyword: | ||
return render_template("search.html", **context_dict) | ||
else: | ||
return render_template("index.html", **context_dict) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これでは index.html
の title
が Search Result for
になります。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そうですね。
context_dict
のsubtitle
を変更するコードを追記します。
templates/index.html
Outdated
@@ -1,3 +1,9 @@ | |||
{% extends "_base.html" %} | |||
{% block main %} | |||
<h1>Registration of equipment and books</h1> | |||
<form action="/search" method="get"> | |||
<label for="query">Enter one of the following keywords: keyword, ISBN code, or ASIN code </label> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
英文なんだから末尾にピリオドが要りますよね。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
失礼しました。追記します。
{% extends "_base.html" %} | ||
{% block main %} | ||
<h1>Search Result</h1> | ||
<h2>Keyword: {{ keyword }}</h2> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index.html
がレンダーされた、と言うテストが必要なのでは?
main.py
Outdated
if keyword: | ||
return render_template("search.html", **context_dict) | ||
else: | ||
context_dict["subtitle"] = "a service to quickly register equipments and books." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 7 in b47d07d
<title>q-lako - {{ subtitle | default("a service to quickly register equipments and books") }}</title> |
default
が設定されてるので要らないです。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
承知しました!修正します!
main.py
Outdated
@app.route("/search", methods=["GET"]) | ||
def search(): | ||
app.logger.info(f"search(): GET {request.full_path}.") | ||
keyword = request.args.get("query", None) | ||
context_dict = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keyword
の有無で処理が変わるので、
それぞれのif文の中でそれぞれに必要最低限の context_dict
を作った方が良さそう。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なるほどですね。
承知しました、修正します!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
確認しました
Describe the PR
To close #9 .
Request input text value to
GET /search
.Screenshots
index.html
with no errorsearch.html
on successDetail of the change
index.html
/search
when the submit button is pressedsearch.html
Anticipated impacts
None.
To reproduce
python main.py
http://0.0.0.0:8888/
Additional context
CSS implemented in Issue #18
Next issue is #11