Add a way to track books that I didn't finish
authorAlex Chan <alex@alexwlchan.net>
Sun, 2 Feb 2020 21:46:34 +0000 (21:46 +0000)
committerAlex Chan <alex@alexwlchan.net>
Sun, 2 Feb 2020 21:46:34 +0000 (21:46 +0000)
scripts/add_book.py
scripts/render_html.py
templates/list_reviews.html
templates/review.html

index 8351c64..2f959c7 100755 (executable)
@@ -86,12 +86,13 @@ def get_review_info():
             choices=["★★★★★", "★★★★☆", "★★★☆☆", "★★☆☆☆", "★☆☆☆☆"],
         ),
         inquirer.Text("format", message="What format did you read it in?"),
+        inquirer.List("did_you_finish", message="Did you finish the book?", choices=["yes", "no"])
     ]
 
     answers = inquirer.prompt(other_questions)
     rating = int(["rating"].count("★"))
 
-    return {"date_read": date_read, "rating": rating, "format": answers["format"]}
+    return {"date_read": date_read, "rating": rating, "format": answers["format"], "did_not_finish": answers["did_you_finish"] == "no"}
 
 
 def save_cover(slug, cover_image_url):
@@ -134,6 +135,9 @@ if __name__ == "__main__":
             "format": review_info["format"],
         }
 
+        if review_info["did_not_finish"]:
+            new_entry["review"]["did_not_finish"] = True
+
         year = review_info["date_read"][:4]
         out_dir = f"reviews/{year}"
     else:
index 194aae8..4e626ec 100755 (executable)
@@ -36,6 +36,7 @@ class Review:
     rating = attr.ib()
     text = attr.ib()
     format = attr.ib()
+    did_not_finish = attr.ib(default=False)
 
 
 @attr.s
index c8eeaab..1ad3b11 100644 (file)
@@ -34,6 +34,9 @@
             {% for _ in range(5 - review_entry.review.rating) %}
             ☆
             {% endfor %}
+            {% if review_entry.review.did_not_finish %}
+            (did not finish)
+            {% endif %}
           </small>
         </p>
       </div>
index 2c12a76..d40e916 100644 (file)
         {%- endif -%}
       </th>
     </tr>
+    <tr>
+      <td>date read:</td>
+      <th>{{ review_entry.review.date_read | render_date }}</th>
+    </tr>
     <tr>
       <td>rating:</td>
       <th>
         {% for _ in range(5 - review_entry.review.rating) %}
         ☆
         {% endfor %}
+        {% if review_entry.review.did_not_finish %}
+        (did not finish)
+        {% endif %}
       </th>
     </tr>
-    <tr>
-      <td>date read:</td>
-      <th>{{ review_entry.review.date_read | render_date }}</th>
-    </tr>
   </table>
 
   {{ review_entry.review.text | render_markdown | safe }}