diff --git a/library/csvparser/csvparser.py b/library/csvparser/csvparser.py index e4d8d8f..9e04266 100644 --- a/library/csvparser/csvparser.py +++ b/library/csvparser/csvparser.py @@ -1,3 +1,6 @@ +"""This parses the varlib.csv but only in a way +that is actually useful for the site""" + import csv import os @@ -17,10 +20,14 @@ def getpublications(): csv_as_dict = csv.DictReader(libcsv) publications = {} for row in csv_as_dict: + year = row["Year"] + if not year: + year = "Unknown" pubinfo = { "Title": row["Publication"], "Author": row["Author"], "Type": row["Type"], + "Year": year, } publications[row["Id"]] = pubinfo return publications @@ -44,8 +51,12 @@ def getyears(): csv_as_dict = csv.DictReader(libcsv) listofyears = [] for row in csv_as_dict: - if row["Year"] not in listofyears: - listofyears.append(row["Year"]) + uniqueyear = row["Year"] + if not uniqueyear: + uniqueyear = "Unknown" + if uniqueyear not in listofyears: + listofyears.append(uniqueyear) + listofyears.sort() return listofyears diff --git a/library/page.py b/library/page.py index 642ee67..01a61ce 100644 --- a/library/page.py +++ b/library/page.py @@ -1,4 +1,4 @@ -"""This is the main flask page code""" +"""This is the main flask library page""" import flask @@ -11,8 +11,7 @@ APP = flask.Flask(__name__, static_folder="static") @APP.route("/") def index(): - """Main route""" - # parse csv, render template with a few elements from the csv + """Main route, shows all the books and you can filter them, a bit""" pubtypes = gettypes() pubyears = getyears() publicatons = getpublications() @@ -27,15 +26,14 @@ def index(): @APP.route("/") def show_book(publicationID): - """route for a publication""" + """route for a publication, still needs to be made""" # parse csv, render template with full list. return render_template("publication.html") @APP.route("/") def upload_book(publication): - """upload a new book""" - # + """upload a new book, still needs to be made""" return render_template("upload.html") diff --git a/library/templates/index.html b/library/templates/index.html index c3f87c1..a8f64fa 100644 --- a/library/templates/index.html +++ b/library/templates/index.html @@ -7,7 +7,7 @@
diff --git a/library/templates/menu.html b/library/templates/menu.html index ae53c45..1190292 100644 --- a/library/templates/menu.html +++ b/library/templates/menu.html @@ -5,8 +5,16 @@ + {% endblock menu %}