From 44cc91c26a818366314f778a6b700bf2128c3f2f Mon Sep 17 00:00:00 2001 From: FrederikBaerentsen <frederik+gitea@baerentsen.net> Date: Fri, 27 Dec 2024 10:32:01 +0100 Subject: [PATCH] Added retirement info to wishlist --- app.py | 14 +++++++++++++- templates/wishlist.html | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 5a972d0..c4378c1 100644 --- a/app.py +++ b/app.py @@ -5,7 +5,7 @@ from flask_socketio import SocketIO from threading import Thread from pprint import pprint as pp from pathlib import Path -import time,random,string,sqlite3 +import time,random,string,sqlite3,csv import numpy as np import re #regex import rebrick #rebrickable api @@ -547,12 +547,24 @@ def wishlist(): cursor.close() conn.close() + retired_sets_dict = {} + + with open('retired_sets.csv', mode='r', encoding='utf-8') as csvfile: + reader = csv.reader(csvfile) + header = next(reader) + for row in reader: + key = row[2] + retired_sets_dict[key] = row + conn = sqlite3.connect('app.db') cursor = conn.cursor() cursor.execute('SELECT * from wishlist;') results = cursor.fetchall() wishlist = [list(i) for i in results] + for w in wishlist: + set_num = w[0].split('-')[0] + w.append(retired_sets_dict.get(set_num,[""]*7)[6]) if wishlist == None or wishlist == '': wishlist = '' conn.commit() diff --git a/templates/wishlist.html b/templates/wishlist.html index 8f8a2e1..b8798f6 100644 --- a/templates/wishlist.html +++ b/templates/wishlist.html @@ -234,6 +234,7 @@ background-color: white; <th class="fixed-width">Name</th> <th style="text-align: center;" class="fixed-width hidden-mobile">Year</th> <th style="text-align: center;" class="fixed-width hidden-mobile">Parts</th> + <th class="fixed-width hidden-mobile">Retirement Date</th> <th style="text-align: center;" class="sorttable_nosort">Delete</th> </tr> </thead> @@ -245,6 +246,7 @@ background-color: white; <td>{{ sets[1] }}</td> <td style="text-align:center;" class="hidden-mobile">{{ sets[2] }}</td> <td style="text-align:center;" class="hidden-mobile">{{ sets[4] }}</td> + <td class="hidden-mobile">{{ sets[8] }}</td> <td style="text-align:center;"> <form method="POST" style="margin:0"> <input type="hidden" name="set_num" value="{{ sets[0] }}">