From dff079f86fa85271561e4deb1ec76b576f35c19d Mon Sep 17 00:00:00 2001 From: Gabriel De Los Rios Date: Sat, 2 Nov 2024 18:28:11 -0300 Subject: [PATCH] feat(utils): adds routes constants dictionary and db utils --- app/utils/__init__.py | 2 ++ app/utils/db_utils.py | 16 ++++++++++++++++ app/utils/route_const.py | 10 ++++++++++ 3 files changed, 28 insertions(+) create mode 100644 app/utils/__init__.py create mode 100644 app/utils/db_utils.py create mode 100644 app/utils/route_const.py diff --git a/app/utils/__init__.py b/app/utils/__init__.py new file mode 100644 index 0000000..78f2e4d --- /dev/null +++ b/app/utils/__init__.py @@ -0,0 +1,2 @@ +from app.utils.db_utils import DBUtils +from app.utils.route_const import ROUTES \ No newline at end of file diff --git a/app/utils/db_utils.py b/app/utils/db_utils.py new file mode 100644 index 0000000..2b4bdeb --- /dev/null +++ b/app/utils/db_utils.py @@ -0,0 +1,16 @@ +from app.extensions import db +from app.models.user import User +from app.models.pet import Pet +from app.models.pet_kind import PetKind +from app.models.adoptions import Adoptions +from app.models.adoption_status import AdoptionStatus + +class DBUtils(): + def setup_db(app): + if not app: + Exception("this function needs app context to be ran, please provide app") + with app.app_context(): + db.create_all() + + def drop_db(): + db.drop_all() diff --git a/app/utils/route_const.py b/app/utils/route_const.py new file mode 100644 index 0000000..0e96fd2 --- /dev/null +++ b/app/utils/route_const.py @@ -0,0 +1,10 @@ +ROUTES = { + 'home': '/', + 'users': { + 'login' : '/users/login', + 'register' : '/users/register', + }, + 'pets': '/pets', + 'about-us' : '/us/about', + 'contact-us' : '/us/contact' +} \ No newline at end of file