Skip to content

Commit 0d8aa16

Browse files
feat: Update file paths for pre-defined users and cache in models and utils
- Update the file path for pre-defined users in `src/models/__init__.py` to use the `ROOT_DIR` variable - Update the file path for pre-defined users in `src/utils.py` to use the `ROOT_DIR` variable - Add `ROOT_DIR` variable to `src/models/__init__.py` and `src/utils.py` to store the root directory path
1 parent c85e2cf commit 0d8aa16

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/models/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
from flask_login import current_user
1212
from werkzeug.security import generate_password_hash
1313
import json
14+
import os
1415

15-
16+
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
1617

1718
with app.app_context():
1819
print("Creating tables")
@@ -27,7 +28,7 @@
2728
db.session.add(FeatureToggleSettings(user_id=user.id))
2829
db.session.commit()
2930

30-
pre_defined_users_json = "src/assets/predefine_user.json"
31+
pre_defined_users_json = os.path.join(ROOT_DIR, "src/assets/predefine_user.json")
3132
with open(pre_defined_users_json, "r") as file:
3233
pre_defined_users = json.load(file)
3334
for user in pre_defined_users:

src/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from src.models import UserDashboardSettings, ApplicationGeneralSettings
1010

11+
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1112
# Simple in-memory cache for specific data with individual timestamps
1213
cache = {}
1314
enable_cahce = True

0 commit comments

Comments
 (0)