partsdb

electronic parts inventory
git clone https://git.e1e0.net/partsdb.git
Log | Files | Refs | README | LICENSE

commit 5f65f13d56b474e6253df8f7c357a35b6afbed5c
parent 5ea47951ce51a03f2753167bfbfc71e4280b1efe
Author: Paco Esteban <paco@e1e0.net>
Date:   Tue, 10 Oct 2023 17:57:43 +0200

add generation time to all pages

Diffstat:
Mpartsdb/exports/templates/cat.html | 3+++
Mpartsdb/exports/templates/index.html | 3+++
Mpartsdb/exports/templates/part.html | 3+++
Mpartsdb/exports/templates/storage.html | 3+++
Mpartsdb/exports/templates/style.css | 5+++++
Mpartsdb/helpers.py | 33+++++++++++++++++++++++++++++----
6 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/partsdb/exports/templates/cat.html b/partsdb/exports/templates/cat.html @@ -39,5 +39,8 @@ </tr> {% endfor %} </table> + <div class="footer"> + Last generated: {{ time_generated }} + </div> </body> </html> diff --git a/partsdb/exports/templates/index.html b/partsdb/exports/templates/index.html @@ -38,5 +38,8 @@ </ul> </div> </div> + <div class="footer"> + Last generated: {{ time_generated }} + </div> </body> </html> diff --git a/partsdb/exports/templates/part.html b/partsdb/exports/templates/part.html @@ -75,5 +75,8 @@ </tr> </tbody> </table> + <div class="footer"> + Last generated: {{ time_generated }} + </div> </body> </html> diff --git a/partsdb/exports/templates/storage.html b/partsdb/exports/templates/storage.html @@ -39,5 +39,8 @@ </tr> {% endfor %} </table> + <div class="footer"> + Last generated: {{ time_generated }} + </div> </body> </html> diff --git a/partsdb/exports/templates/style.css b/partsdb/exports/templates/style.css @@ -41,3 +41,8 @@ h1 { grid-template-areas: 'indexLogo indexTitle indexTitle indexTitle indexTitle indexTitle' 'catList catList catList storageList storageList storageList'; } + +.footer { + margin: 20px 0px 0px 5px; + font-size: small; +} diff --git a/partsdb/helpers.py b/partsdb/helpers.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # vim:fenc=utf-8 +import datetime import json import subprocess import tempfile @@ -146,25 +147,49 @@ def open_file(content, extension): def html_main_index(dest_folder, categories, storages, env): tpl = env.get_template("index.html") with open(f"{dest_folder}/index.html", "w") as f: - f.write(tpl.render(cat=categories, sto=storages)) + f.write( + tpl.render( + cat=categories, + sto=storages, + time_generated=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), + ) + ) def html_category_index(dest_folder, category, parts, env): tpl = env.get_template("cat.html") with open(f"{dest_folder}/cat_list_{category['id']}.html", "w") as f: - f.write(tpl.render(category=category, parts=parts)) + f.write( + tpl.render( + category=category, + parts=parts, + time_generated=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), + ) + ) def html_storage_index(dest_folder, storage, parts, env): tpl = env.get_template("storage.html") with open(f"{dest_folder}/storage_{storage['id']}.html", "w") as f: - f.write(tpl.render(storage=storage, parts=parts)) + f.write( + tpl.render( + storage=storage, + parts=parts, + time_generated=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), + ) + ) def html_part(dest_folder, part, part_history, env): tpl = env.get_template("part.html") with open(f"{dest_folder}/part_{part['id']}.html", "w") as f: - f.write(tpl.render(part=part, history=part_history)) + f.write( + tpl.render( + part=part, + history=part_history, + time_generated=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), + ) + ) def html_css(dest_folder, env):