log and js for the form panel to apppear

master
grgr 2 years ago
parent 81fa3f1ebc
commit d300b512b7

Binary file not shown.

@ -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 (<table></table>)
# - ⭐ 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

@ -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"
}

@ -3,7 +3,8 @@ body{
}
.formPanel{
background-color: limegreen;
display: none;
background-color: rgb(239, 255, 167);
width: 300px;
height: 400px;
position: absolute;

@ -8,7 +8,7 @@
</head>
<body>
hello here a list of:
<a class="addNew" href="{{url_for('add_new_page')}}"><button id="reference">add new element</button></a>
<button id="new" onclick="openPanel()">add new element</button>
<table>
{% for row in reading_list%}
<tr>
@ -19,7 +19,8 @@
{% endfor %}
</table>
<div class="formPanel">
<div class="formPanel" id="formPanel">
<button onclick="closePanel()">X</button>
<form method="POST" enctype="multipart/form-data">
<input type="text" name="author" placeholder="Author"/>
<input type="text" name="title" placeholder="Title"/>

Loading…
Cancel
Save