# 1- ogni blocco del form dovrebbe essere una tabella a parte
ifrequest.method=='POST':
title=request.form.get('title')
author=request.form.get('author')
description=request.form.get('description')
add_book(author,title,description)
# if author:
# return url_for('add_new_author')
add_new_author()
returnredirect(url_for('home'))
returnrender_template('add_new.html')
# so instead of having a function for everything there will be a unique function to create the category with relative table (it will probably be an augmented "create_table()" function
# def add_new_book():
# if request.method == 'POST':
# title = request.form.get('title')
# author = request.form.get('author')
# description = request.form.get('description')
# add_book(author, title, description)
# # if author:
# # return url_for('add_new_author')
# add_new_author()
# return redirect(url_for('home'))
# return render_template('add_book.html')
defadd_new_author():
print('testetest this function is working')
# if request.method == 'POST':
# table
# the list of books doesn't have to coincide with the list of authors, but when you add a new book that has a new author the function will automacally add a new author so. shall it be in the home page?? (no mettiamo tutto nell'add new page con una funzione che aggiunge ogni elemento del form nella tabella corrispondente, se non esiste, aggiunge una nuova categoria)
# - sort notes (what if notes had their own tag system that interacts with the one of the resources?)
# same goes for authors,create a table of authors that then can relate to biografies and connections for the topics they treat or for their personal connections... too much?
# ----- Notes ----- #
# I wanted to create a reading list for the summer, in which I could add my comments and organize the readings through some personal categories. As I was also interested in relational tables and databases I started to do some tutorials with sqlite. This is the first attempt to apply those tutorials to the library, it's gonna be very basic initially, but I'll try to document the steps on the way. At the moment I have a vague idea of how the project can be developed but I'm really not aware of all the steps for sure.
# So this is the process: I write initially a raw todo list with main steps I want to reach (like using flask, creating database etc), then I try to figure out the steps in-between to accomplish a main step. It ain't easy though.
# I got stuck immediately when I tried to create the Flask application: I needed to register the prefix middleware to be able to see the front-end on the right port and url (asked to kamo and then copy pasted the lines about the prefix middleware from another project on the soupboat)
# I created the first table of the database by running the create_table() funct in the add() url, which was a pretty ugly procedure, but then I could write a simpler function to add_book() that refers directly to that table (not so abstracted in this case, but will fix this part later on)
# getAllRow() is also related to specific table of a db, so need to make it more abstract/general
# In the beginning I wasn't sure that getAllRows() should return something, but as I understood I need to display the rows with jinja and html I got that I need a list of objects (in this case the rows of the db with books) to be able to populate the html table with my data
# ok, it took me a while to understand how to pass the list of dictionaries (the reading list that i got from the funct getAllRows()) to the frontend. but it was because I didn't want to recreate the object of the row again, is there a quicker way to pass the list with all the arguments of its dictionaries?
# yes there was a muh quiker way, just return the function getAllRows directly with the name of the db, it will pass directly the reding list to jinja
# Right now I have something that looks like a very raw table. I'm thinking what's the next step. I'd like to create a system of tags but also a system of notation for each book. I'll do some research on notation and tag systems and a tutorial on relational tables
# It's been a month that I haven't touched this proj. really difficult to pick up on what i did, because there is not a clear method in the documentation either. so now I will try to write the process only here and to reference the (current) lines of things