From d300b512b771ac0a20e81dc3b0e974593b1c3a80 Mon Sep 17 00:00:00 2001 From: grgr Date: Sun, 25 Sep 2022 22:33:05 +0200 Subject: [PATCH] log and js for the form panel to apppear --- library.db | Bin 8192 -> 8192 bytes library.py | 30 ++++++++++++++++++------------ static/addnew_panel.js | 10 ++++++++++ static/style_default.css | 3 ++- templates/home.html | 5 +++-- 5 files changed, 33 insertions(+), 15 deletions(-) diff --git a/library.db b/library.db index 1b975b42795c6d173a80b56586c97a22c7e9358f..74748d7ef4bfab8b1ececb248523a0c84f933f29 100644 GIT binary patch delta 134 zcmZp0XmFSy&B!-V#+jdwLC?RImw|zSk-wjTzkg$)9RK7V{t7u>_E`-4Gx>A*b-2s8 z3%Jd>4Y|3w9&jFF|G|EReb&ap3U(_CUKVlnKh2oN;#Jv36#LA>p mh0GF#^2B0=#5{%6qN4mFh4Rdj4286u#Nupwh0RyQbvOWC5GQ*8 delta 73 zcmZp0XmFSy&B!}Z#+jd&LC?U7mw|zSk-wjTzkg$)9RK7V{t6i$_A3nhGx>A*b-2s8 d3%Jd>4Y|3w9&jFF|G|D`W8oI|%~!;AH~@F$6HNdB diff --git a/library.py b/library.py index 484187f..37acea5 100644 --- a/library.py +++ b/library.py @@ -1,6 +1,6 @@ # THE LIBRARY # -from crypt import methods +# from crypt import methods import os import sqlite3 @@ -130,6 +130,7 @@ app.wsgi_app = PrefixMiddleware(app.wsgi_app, prefix='/soupboat/library') @app.route("/", methods=['GET', 'POST']) +# @app.route("/") def home(): getAllTables('./library.db') @@ -138,9 +139,6 @@ def home(): 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('home.html', reading_list=getAllRows('library.db')) @@ -167,7 +165,7 @@ def add_new_page(): 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_new.html') @@ -186,15 +184,8 @@ def add_new_page(): # return redirect(url_for('home')) # return render_template('add_book.html') -def add_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) - - app.run(port=3148) # ------------------- # TODO: @@ -206,6 +197,8 @@ app.run(port=3148) # - ⭐ getallrows returns a list to be iterated with jinja # - ⭐ and visualize them in the homepage (
) # - ⭐ fetch all tables function +# - current date when posting in new item +# - create new tables # - show all tables # - edit items # - remove item/entry from a table @@ -239,3 +232,16 @@ app.run(port=3148) # 15/09/22 # 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 + +# 24/09/22 +# I've created a repo on git to be able to work on vsc and I used a virtual environment to develop the flask application. I did it by typing the command $ python -m venv folder_name +# I have a question: can I use flask without venv? +# Actually yes, even if at first I thought it wasn't possible, just because I blindly trusted people on Stack overflow, or by following the process on flask tutorials I got to set up this virtaulenv. The difference without the virtual env is that all the dependencies that I need would be installed globally on my computer and it might be unconvenient when a version of them will change or if I have a lot of stuff to download. So it turned out that creatinf a virtualenv could be a good practice. + +# VIRTUAL ENVIRONMENT: +# "The virtual environment is basically a room open for your specific coding project. Instead of using os-wide defined Python or Python packages, it aims to isolate your Python and its dependent packages from all projects that are hosted by your computer." +# https://medium.com/@pinareceaktan/what-is-this-virtual-environments-in-python-and-why-anyone-ever-needs-them-7e3e682f9d2 +# "No, there is no requirement to use a virtualenv. No project ever would require you to use one; it is just a method of insulating a collection of Python libraries from other projects. + +# I personally do strongly recommend you use a virtualenv, because it makes it much, much easier to swap out versions of libraries and not affect other Python projects." +# https://stackoverflow.com/questions/32756711/is-it-necessary-to-use-virtualenv-to-use-flask-framework diff --git a/static/addnew_panel.js b/static/addnew_panel.js index e69de29..383c156 100644 --- a/static/addnew_panel.js +++ b/static/addnew_panel.js @@ -0,0 +1,10 @@ + + + +// document.getElementById("new").addEventListener("click", openPanel); +function openPanel(){ + document.getElementById("formPanel").style.display = "block" +} +function closePanel(){ + document.getElementById("formPanel").style.display = "none" +} \ No newline at end of file diff --git a/static/style_default.css b/static/style_default.css index 0f2c668..4fa660c 100644 --- a/static/style_default.css +++ b/static/style_default.css @@ -3,7 +3,8 @@ body{ } .formPanel{ - background-color: limegreen; + display: none; + background-color: rgb(239, 255, 167); width: 300px; height: 400px; position: absolute; diff --git a/templates/home.html b/templates/home.html index 1e046ca..86a47dd 100644 --- a/templates/home.html +++ b/templates/home.html @@ -8,7 +8,7 @@ hello here a list of: - + {% for row in reading_list%} @@ -19,7 +19,8 @@ {% endfor %}
-
+
+