From 9f4084a4d7cbfea88805e1fd9d074f27e7f9b3e4 Mon Sep 17 00:00:00 2001 From: Jadowyne Ulve Date: Sat, 26 Apr 2025 21:17:47 -0500 Subject: [PATCH] Update pack. structure from scripts to application --- {scripts => application}/__init__.py | 0 .../__pycache__/__init__.cpython-312.pyc | Bin .../__pycache__/postsqldb.cpython-312.pyc | Bin {scripts => application}/postsqldb.py | 0 {scripts => application}/recipes/__init__.py | 0 .../__pycache__/__init__.cpython-312.pyc | Bin .../database_recipes.cpython-312.pyc | Bin 12879 -> 12827 bytes .../__pycache__/recipes_api.cpython-312.pyc | Bin 17701 -> 17282 bytes .../recipes/database_recipes.py | 26 +++++++++--------- .../recipes/recipes_api.py | 12 ++------ .../recipes/sql/getItemData.sql | 0 .../recipes/sql/getRecipeByID.sql | 0 .../recipes/sql/getRecipes.sql | 0 .../recipes/sql/getRecipesCount.sql | 0 .../recipes/sql/itemsModal.sql | 0 .../recipes/sql/itemsModalCount.sql | 0 .../recipes/sql/postRecipe.sql | 0 .../recipes/sql/postRecipeItem.sql | 0 .../recipes/sql/postUpdateRecipe.sql | 0 .../recipes/sql/postUpdateRecipeItem.sql | 0 webserver.py | 2 +- 21 files changed, 16 insertions(+), 24 deletions(-) rename {scripts => application}/__init__.py (100%) rename {scripts => application}/__pycache__/__init__.cpython-312.pyc (100%) rename {scripts => application}/__pycache__/postsqldb.cpython-312.pyc (100%) rename {scripts => application}/postsqldb.py (100%) rename {scripts => application}/recipes/__init__.py (100%) rename {scripts => application}/recipes/__pycache__/__init__.cpython-312.pyc (100%) rename {scripts => application}/recipes/__pycache__/database_recipes.cpython-312.pyc (52%) rename {scripts => application}/recipes/__pycache__/recipes_api.cpython-312.pyc (58%) rename {scripts => application}/recipes/database_recipes.py (88%) rename {scripts => application}/recipes/recipes_api.py (97%) rename {scripts => application}/recipes/sql/getItemData.sql (100%) rename {scripts => application}/recipes/sql/getRecipeByID.sql (100%) rename {scripts => application}/recipes/sql/getRecipes.sql (100%) rename {scripts => application}/recipes/sql/getRecipesCount.sql (100%) rename {scripts => application}/recipes/sql/itemsModal.sql (100%) rename {scripts => application}/recipes/sql/itemsModalCount.sql (100%) rename {scripts => application}/recipes/sql/postRecipe.sql (100%) rename {scripts => application}/recipes/sql/postRecipeItem.sql (100%) rename {scripts => application}/recipes/sql/postUpdateRecipe.sql (100%) rename {scripts => application}/recipes/sql/postUpdateRecipeItem.sql (100%) diff --git a/scripts/__init__.py b/application/__init__.py similarity index 100% rename from scripts/__init__.py rename to application/__init__.py diff --git a/scripts/__pycache__/__init__.cpython-312.pyc b/application/__pycache__/__init__.cpython-312.pyc similarity index 100% rename from scripts/__pycache__/__init__.cpython-312.pyc rename to application/__pycache__/__init__.cpython-312.pyc diff --git a/scripts/__pycache__/postsqldb.cpython-312.pyc b/application/__pycache__/postsqldb.cpython-312.pyc similarity index 100% rename from scripts/__pycache__/postsqldb.cpython-312.pyc rename to application/__pycache__/postsqldb.cpython-312.pyc diff --git a/scripts/postsqldb.py b/application/postsqldb.py similarity index 100% rename from scripts/postsqldb.py rename to application/postsqldb.py diff --git a/scripts/recipes/__init__.py b/application/recipes/__init__.py similarity index 100% rename from scripts/recipes/__init__.py rename to application/recipes/__init__.py diff --git a/scripts/recipes/__pycache__/__init__.cpython-312.pyc b/application/recipes/__pycache__/__init__.cpython-312.pyc similarity index 100% rename from scripts/recipes/__pycache__/__init__.cpython-312.pyc rename to application/recipes/__pycache__/__init__.cpython-312.pyc diff --git a/scripts/recipes/__pycache__/database_recipes.cpython-312.pyc b/application/recipes/__pycache__/database_recipes.cpython-312.pyc similarity index 52% rename from scripts/recipes/__pycache__/database_recipes.cpython-312.pyc rename to application/recipes/__pycache__/database_recipes.cpython-312.pyc index 5eacd7c357a88d54068e9f6b887620a1b64ae036..bc3782010ad181b4ea1ca31aa1381cd6cb592e85 100644 GIT binary patch delta 815 zcmZ8fT}TvB6rQ{DqqBR*-F4S-R^5Nnbl2P^vrJMpH&E!uLVM_G7k6{lGIg9@Vk93b zC?Z-;kz`Oo(1QfY1Z_d2*n?1zG*FS-gAmkHExs1g9eWu&aKC%_?m36=oO|A9<}$)t zL9kN9WA4-(lb{I)qD=O1@XrAXGpU~e_OWUC<+mI6+QN%g1#PDp!^ z1+Ga6g276^oyk+GYR9U4)k128agK8Xy@^Phg585ZE%=N8B$}BUxo2KdhXWvjb@*C%0)A>r(%% z%Xe?UB1hq{@3M9>%pvWQ|BnT?m}j*X+JT~g!b7(GI^VT5fTE(M!?$T1HN|P0jS~ny zMqg=><_{JeGd;m(qZdNaXSh#y_LBla4y_E5eG}p4&N&TQkI;DAYW|4DIpa6vHt@%L g@H%nJG(zYr6@<}vvZ@^7kTgq|DRMm+g5~)2zerE_TmS$7 delta 833 zcmYjPT}V@L6u{C>5cibcBvFr|F31Dm6Fth+y5Z0cmJ79)odGgkI9jR{jgf zs&LVc4uA$T$N(Od>@ks9_G0Y%v_Qo8TSG!#$UPCrHTSX2?`&VcKkigkBGC z&9i6>o^tnL-ch2Zj*OKTmfT~laa8FgMv+irRp3<6s-RPWhfCHDt*BDF3PteQy3gTP zXh?Z6C&I7^Y{^=3XCyfS=O(&yI1gdb0+U+Gv?N#-ZOs`nD|Bti_0bGz+KHCota!r5 zXgFscQ(zrerQE96SSK0YnZp#=*u-@P4(dY2+ZJWq6TY*7NSAdQsrPmpwAhLn?t{oE zF*t5(yyddMLt72>BA2QWTtgl_L4ns^jVK7)Jp`SgVWw;^%-W|A1AUcd=n-~#V(R9u zEt8xI|E50^jfaN@;^(Dk_*8sQs+BJn_5F7`s}2|RTMvQJc|}{7n2?K0 zFA{7;LEBY_2(R3FI-sAgz9gR10f?R^4xf<_Lt)cgz9J!H^~I Vrjc!$$YF|m(6i}MA(#x__zQVN_x%6> diff --git a/scripts/recipes/__pycache__/recipes_api.cpython-312.pyc b/application/recipes/__pycache__/recipes_api.cpython-312.pyc similarity index 58% rename from scripts/recipes/__pycache__/recipes_api.cpython-312.pyc rename to application/recipes/__pycache__/recipes_api.cpython-312.pyc index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tID`K&wc$&syYy-Y}#Xyb4;Un*2nVdmc7*)lD6CX@*Zv0k= zSk>#0LGAOj6DbK}E!VMRLE+$NwZh9(96NVUjVtg>XH=<)1HXg&OF-(m3;xSBw z_&7bP*aa4HDY}~#U=6Y+={{)T2Qne#TZcsE9N$X(&iG(k|9_>fds5eD{-!I{Z=bsD z-@M}ccU8@0-|ec_6>lLpv4Lz0G+)Y}&tExtw=#IH=hDFWfh)5gS9aX>2hS~BT0Fn_ zcI01MXFvAOeeIG}$3saD$SYM3D*49A=I*3PJ#3 P=L2`)g~=Y`#L#~L)?2RA diff --git a/scripts/recipes/database_recipes.py b/application/recipes/database_recipes.py similarity index 88% rename from scripts/recipes/database_recipes.py rename to application/recipes/database_recipes.py index 0284e1d..e4886dd 100644 --- a/scripts/recipes/database_recipes.py +++ b/application/recipes/database_recipes.py @@ -1,4 +1,4 @@ -from scripts import postsqldb +from application import postsqldb import config import psycopg2 @@ -6,7 +6,7 @@ def getModalSKUs(site, payload, convert=True): database_config = config.config() with psycopg2.connect(**database_config) as conn: with conn.cursor() as cur: - with open("scripts/recipes/sql/itemsModal.sql") as file: + with open("application/recipes/sql/itemsModal.sql") as file: sql = file.read().replace("%%site_name%%", site) cur.execute(sql, payload) rows = cur.fetchall() @@ -14,7 +14,7 @@ def getModalSKUs(site, payload, convert=True): if rows and convert: rows = [postsqldb.tupleDictionaryFactory(cur.description, row) for row in rows] - with open("scripts/recipes/sql/itemsModalCount.sql") as file: + with open("application/recipes/sql/itemsModalCount.sql") as file: sql = file.read().replace("%%site_name%%", site) cur.execute(sql) @@ -30,7 +30,7 @@ def getItemData(site:str, payload:tuple, convert:bool=True): try: with psycopg2.connect(**database_config) as conn: with conn.cursor() as cur: - with open("scripts/recipes/sql/getItemData.sql") as file: + with open("application/recipes/sql/getItemData.sql") as file: sql = file.read().replace("%%site_name%%", site) cur.execute(sql, payload) rows = cur.fetchone() @@ -45,9 +45,9 @@ def getItemData(site:str, payload:tuple, convert:bool=True): def getRecipes(site:str, payload:tuple, convert=True): recordset = [] count = 0 - with open("scripts/recipes/sql/getRecipes.sql", "r+") as file: + with open("application/recipes/sql/getRecipes.sql", "r+") as file: sql = file.read().replace("%%site_name%%", site) - with open(f"scripts/recipes/sql/getRecipesCount.sql", "r+") as file: + with open(f"application/recipes/sql/getRecipesCount.sql", "r+") as file: sqlcount = file.read().replace("%%site_name%%", site) try: database_config = config.config() @@ -67,10 +67,10 @@ def getRecipes(site:str, payload:tuple, convert=True): def getRecipe(site, payload:tuple, convert=True): database_config = config.config() + with open(f"application/recipes/sql/getRecipeByID.sql", "r+") as file: + sql = file.read().replace("%%site_name%%", site) try: with psycopg2.connect(**database_config) as conn: - with open(f"scripts/recipes/sql/getRecipeByID.sql", "r+") as file: - sql = file.read().replace("%%site_name%%", site) with conn.cursor() as cur: cur.execute(sql, payload) rows = cur.fetchone() @@ -82,7 +82,7 @@ def getRecipe(site, payload:tuple, convert=True): except (Exception, psycopg2.DatabaseError) as error: raise postsqldb.DatabaseError(error, payload, sql) -def getPicturePath(site:str, payload:tuple, convert:bool=True): +def getPicturePath(site:str, payload:tuple): database_config = config.config() with psycopg2.connect(**database_config) as conn: with conn.cursor() as cur: @@ -93,7 +93,7 @@ def getPicturePath(site:str, payload:tuple, convert:bool=True): def postAddRecipe(site:str, payload:tuple, convert:bool=True): database_config = config.config() record = () - with open("scripts/recipes/sql/postRecipe.sql") as file: + with open("application/recipes/sql/postRecipe.sql") as file: sql = file.read().replace("%%site_name%%", site) try: with psycopg2.connect(**database_config) as conn: @@ -111,7 +111,7 @@ def postAddRecipe(site:str, payload:tuple, convert:bool=True): def postAddRecipeItem(site:str, payload:tuple, convert:bool=True): database_config = config.config() record = () - with open("scripts/recipes/sql/postRecipeItem.sql") as file: + with open("application/recipes/sql/postRecipeItem.sql") as file: sql = file.read().replace("%%site_name%%", site) try: with psycopg2.connect(**database_config) as conn: @@ -132,7 +132,7 @@ def postUpdateRecipe(site:str, payload:tuple, convert:bool=True): with psycopg2.connect(**database_config) as conn: with conn.cursor() as cur: set_clause, values = postsqldb.updateStringFactory(payload['update']) - with open("scripts/recipes/sql/postUpdateRecipe.sql") as file: + with open("application/recipes/sql/postUpdateRecipe.sql") as file: sql = file.read().replace("%%site_name%%", site).replace("%%set_clause%%", set_clause) values.append(payload['id']) cur.execute(sql, values) @@ -149,7 +149,7 @@ def postUpdateRecipeItem(site:str, payload:tuple, convert:bool=True): with psycopg2.connect(**database_config) as conn: with conn.cursor() as cur: set_clause, values = postsqldb.updateStringFactory(payload['update']) - with open("scripts/recipes/sql/postUpdateRecipeItem.sql") as file: + with open("application/recipes/sql/postUpdateRecipeItem.sql") as file: sql = file.read().replace("%%site_name%%", site).replace("%%set_clause%%", set_clause) values.append(payload['id']) cur.execute(sql, values) diff --git a/scripts/recipes/recipes_api.py b/application/recipes/recipes_api.py similarity index 97% rename from scripts/recipes/recipes_api.py rename to application/recipes/recipes_api.py index b047a18..1c40883 100644 --- a/scripts/recipes/recipes_api.py +++ b/application/recipes/recipes_api.py @@ -5,12 +5,10 @@ from main import unfoldCostLayers from user_api import login_required import os import postsqldb, webpush -from scripts.recipes import database_recipes -from scripts import postsqldb as db -from flask_restx import Api, fields +from application.recipes import database_recipes +from application import postsqldb as db recipes_api = Blueprint('recipes_api', __name__) -model_api = Api(recipes_api) @recipes_api.route("/recipes") @login_required @@ -140,14 +138,8 @@ def getItems(): return jsonify({"items":recordset, "end":math.ceil(count/limit), "error":False, "message":"items fetched succesfully!"}) return jsonify({"items":recordset, "end":math.ceil(count/limit), "error":True, "message":"There was an error with this GET statement"}) -update_model = model_api.model('model', { - 'id': fields.Integer(min=1), - 'update': fields.Raw(required=True, description="all the data to be updated!") -}) - @recipes_api.route('/recipe/postUpdate', methods=["POST"]) @login_required -@model_api.expect(update_model) def postUpdate(): """ This is an endpoint for updating an RecipeTuple in the sites recipes table --- diff --git a/scripts/recipes/sql/getItemData.sql b/application/recipes/sql/getItemData.sql similarity index 100% rename from scripts/recipes/sql/getItemData.sql rename to application/recipes/sql/getItemData.sql diff --git a/scripts/recipes/sql/getRecipeByID.sql b/application/recipes/sql/getRecipeByID.sql similarity index 100% rename from scripts/recipes/sql/getRecipeByID.sql rename to application/recipes/sql/getRecipeByID.sql diff --git a/scripts/recipes/sql/getRecipes.sql b/application/recipes/sql/getRecipes.sql similarity index 100% rename from scripts/recipes/sql/getRecipes.sql rename to application/recipes/sql/getRecipes.sql diff --git a/scripts/recipes/sql/getRecipesCount.sql b/application/recipes/sql/getRecipesCount.sql similarity index 100% rename from scripts/recipes/sql/getRecipesCount.sql rename to application/recipes/sql/getRecipesCount.sql diff --git a/scripts/recipes/sql/itemsModal.sql b/application/recipes/sql/itemsModal.sql similarity index 100% rename from scripts/recipes/sql/itemsModal.sql rename to application/recipes/sql/itemsModal.sql diff --git a/scripts/recipes/sql/itemsModalCount.sql b/application/recipes/sql/itemsModalCount.sql similarity index 100% rename from scripts/recipes/sql/itemsModalCount.sql rename to application/recipes/sql/itemsModalCount.sql diff --git a/scripts/recipes/sql/postRecipe.sql b/application/recipes/sql/postRecipe.sql similarity index 100% rename from scripts/recipes/sql/postRecipe.sql rename to application/recipes/sql/postRecipe.sql diff --git a/scripts/recipes/sql/postRecipeItem.sql b/application/recipes/sql/postRecipeItem.sql similarity index 100% rename from scripts/recipes/sql/postRecipeItem.sql rename to application/recipes/sql/postRecipeItem.sql diff --git a/scripts/recipes/sql/postUpdateRecipe.sql b/application/recipes/sql/postUpdateRecipe.sql similarity index 100% rename from scripts/recipes/sql/postUpdateRecipe.sql rename to application/recipes/sql/postUpdateRecipe.sql diff --git a/scripts/recipes/sql/postUpdateRecipeItem.sql b/application/recipes/sql/postUpdateRecipeItem.sql similarity index 100% rename from scripts/recipes/sql/postUpdateRecipeItem.sql rename to application/recipes/sql/postUpdateRecipeItem.sql diff --git a/webserver.py b/webserver.py index e07c9cc..1675ae2 100644 --- a/webserver.py +++ b/webserver.py @@ -8,7 +8,7 @@ from workshop_api import workshop_api import database import postsqldb from webpush import trigger_push_notifications_for_subscriptions -from scripts.recipes import recipes_api +from application.recipes import recipes_api from flasgger import Swagger