From de13e4199a3c85068320bc7a602e675c945575b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fukan=20=C3=9Crker?= Date: Mon, 15 Jan 2024 21:22:40 +0300 Subject: [PATCH 1/8] new debugging messages and constant variables added (app-name, app-root-path) --- app.py | 26 +++++++++++++++++++++----- constants.py | 2 ++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 7fbb0598..6267fbd3 100644 --- a/app.py +++ b/app.py @@ -38,27 +38,37 @@ from dbChecker import dbFolder, usersTable, postsTable, commentsTable from constants import ( + LOG_IN, APP_HOST, + APP_NAME, DEBUG_MODE, TAILWIND_UI, - LOG_IN, REGISTRATION, LOG_FILE_ROOT, + APP_ROOT_PATH, APP_SECRET_KEY, SESSION_PERMANENT, ) + from UISelector import TEMPLATE_FOLDER, STATIC_FOLDER -app = Flask(__name__, template_folder=TEMPLATE_FOLDER, static_folder=STATIC_FOLDER) +app = Flask( + import_name=APP_NAME, + root_path=APP_ROOT_PATH, + static_folder=STATIC_FOLDER, + template_folder=TEMPLATE_FOLDER, +) + app.secret_key = APP_SECRET_KEY app.config["SESSION_PERMANENT"] = SESSION_PERMANENT csrf = CSRFProtect(app) - message("1", f"APP DEBUG MODE: {DEBUG_MODE}") +message("3", f"APP NAME: {APP_NAME}") message("3", f"APP HOST: {APP_HOST}") message("3", f"APP SECRET KEY: {APP_SECRET_KEY}") message("3", f"APP SESSION PERMANENT: {SESSION_PERMANENT}") +message("3", f"APP ROOT PATH: {APP_ROOT_PATH}") message("3", f"LOG FILE ROOT: {LOG_FILE_ROOT}") message("3", f"LOG IN: {LOG_IN}") message("3", f"REGISTRATION: {REGISTRATION}") @@ -119,8 +129,14 @@ def handle_csrf_error(e): app.register_blueprint(adminPanelCommentsBlueprint) app.register_blueprint(changeProfilePictureBlueprint) -message("2", "APP STARTED SUCCESSFULLY") match __name__: case "__main__": - app.run(debug=DEBUG_MODE, host=APP_HOST) + try: + message("2", "APP STARTED SUCCESSFULLY") + app.run(debug=DEBUG_MODE, host=APP_HOST) + except: + message("1", "ERROR: APP IS DOWN") + app.run(debug=DEBUG_MODE, host=APP_HOST) + finally: + message("3", "APP SHUT DOWN") diff --git a/constants.py b/constants.py index 2480eeaa..894cb78d 100644 --- a/constants.py +++ b/constants.py @@ -1,5 +1,7 @@ from helpers import secrets, socket +APP_NAME = "flaskBlog" # NAME OF THE FLASK APP. +APP_ROOT_PATH = "." # THE PATH TO THE ROOT OF THE APP FILES. APP_HOST = socket.gethostbyname(socket.gethostname()) # FLASK APP'S HOST/PORT. DEBUG_MODE = True # TURN ON/OFF FLASK DEBUG MODE. TAILWIND_UI = False # SELECT TAILWIND-UI/STANDARD-UI. From 398c811bcb857b4a927586b36cfc2bf43c0a63fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fukan=20=C3=9Crker?= Date: Mon, 15 Jan 2024 21:27:47 +0300 Subject: [PATCH 2/8] Update changeTheme.html --- templates/tailwindUI/changeTheme.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/tailwindUI/changeTheme.html b/templates/tailwindUI/changeTheme.html index 77315254..e3be01d9 100644 --- a/templates/tailwindUI/changeTheme.html +++ b/templates/tailwindUI/changeTheme.html @@ -1,6 +1,6 @@
{%else%} - - Date: Mon, 15 Jan 2024 22:49:53 +0300 Subject: [PATCH 6/8] forms select none added to place holders --- forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forms.py b/forms.py index 6e09d6c8..978303f4 100644 --- a/forms.py +++ b/forms.py @@ -1,6 +1,6 @@ from wtforms import validators, Form, StringField, PasswordField, TextAreaField -inputStyle = "w-80 h-12 mb-4 mx-auto p-2 rounded-md text-center outline-rose-500 bg-transparent focus:outline-none focus:ring focus:ring-rose-500 duration-100 border-2 border-gray-500/25 focus:border-0 block shadow-md" +inputStyle = "w-80 h-12 mb-4 mx-auto p-2 rounded-md text-center outline-rose-500 bg-transparent focus:outline-none focus:ring focus:ring-rose-500 duration-100 border-2 border-gray-500/25 focus:border-0 block shadow-md select-none" class commentForm(Form): From 32015f2713a49b26d54ff13f4ae7ccf4cd539d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fukan=20=C3=9Crker?= Date: Mon, 15 Jan 2024 22:50:02 +0300 Subject: [PATCH 7/8] admin panel user page styled --- templates/tailwindUI/adminPanelUsers.html | 92 ++++++++++++++--------- 1 file changed, 55 insertions(+), 37 deletions(-) diff --git a/templates/tailwindUI/adminPanelUsers.html b/templates/tailwindUI/adminPanelUsers.html index cebe9c85..e6f95991 100644 --- a/templates/tailwindUI/adminPanelUsers.html +++ b/templates/tailwindUI/adminPanelUsers.html @@ -1,66 +1,84 @@ {% extends 'layout.html'%} {%block head%} Admin Panel {% endblock head %} {%block body%} -
-

Users

+
+

Users

{% for user in users %} -
-
-

ID: {{user[0]}}

-

Role: {{user[5]}}

+
+
+ {{user[1]}} +

+ {{user[1]}} +

-
-

- User Name: - {{user[1]}} +

+

+ ID: {{user[0]}} +

+

+ Role: {{user[5]}}

- {{user[1]}}
-
-

email: {{user[2]}}

-

Points: {{user[6]}}

+
+

+ email: {{user[2]}} +

+

+ Points: {{user[6]}} +

-
-

Join Date: {{user[7]}}

-

Join Time: {{user[8]}}

+
+

+ Join Date: {{user[7]}} +

+

+ Join Time: {{user[8]}} +

-
+
{% if user[5] == "admin" %} - set user role to user + set user role to user {% else %} - set user role to adminset user role to admin {% endif %}
{% endfor %}
- - - + {% endblock body %} From de6c09a19108b6405f2bfcd63c4a9537c010bd5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fukan=20=C3=9Crker?= Date: Mon, 15 Jan 2024 22:51:33 +0300 Subject: [PATCH 8/8] select none added to forms --- templates/tailwindUI/login.html | 4 ++-- templates/tailwindUI/signup.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/tailwindUI/login.html b/templates/tailwindUI/login.html index b82b4011..f9cf0228 100644 --- a/templates/tailwindUI/login.html +++ b/templates/tailwindUI/login.html @@ -10,14 +10,14 @@ border-gray-500/25 focus:border-rose-500 block shadow-md")}} Forgot password? diff --git a/templates/tailwindUI/signup.html b/templates/tailwindUI/signup.html index 395ff1d5..1c4c758d 100644 --- a/templates/tailwindUI/signup.html +++ b/templates/tailwindUI/signup.html @@ -8,7 +8,7 @@ {{form.password()}} {{form.passwordConfirm()}}