diff --git a/docs/developer-info.md b/docs/developer-info.md index 07c64c3b..6cc8338a 100644 --- a/docs/developer-info.md +++ b/docs/developer-info.md @@ -1,17 +1,15 @@ ### Backend Apps -If you planing to extend the Backend with you own apps (api endpoints), -just add you app folder in **ffplayout/apps**. +If you planing to extend the backend with your own apps (api endpoints), +just add your app in folder: **ffplayout/apps**. -If you planing to us a DB, put a **db.py** file in your app. With this `Class`: +If you planing to us a DB, put a **settings.py** file in your app. With this object: -``` -class Connector: - config = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db-name.sqlite3'), - } +```python +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db-name.sqlite3'), } - +} ``` diff --git a/ffplayout/apps/api_player/db.py b/ffplayout/apps/api_player/db.py deleted file mode 100644 index 346cd26b..00000000 --- a/ffplayout/apps/api_player/db.py +++ /dev/null @@ -1,11 +0,0 @@ -import os - -BASE_DIR = os.path.dirname(os.path.abspath(os.path.join(__file__))) - -class Connector: - config = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } - } diff --git a/ffplayout/apps/api_player/settings.py b/ffplayout/apps/api_player/settings.py new file mode 100644 index 00000000..26573881 --- /dev/null +++ b/ffplayout/apps/api_player/settings.py @@ -0,0 +1,10 @@ +import os + +BASE_DIR = os.path.dirname(os.path.abspath(os.path.join(__file__))) + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} diff --git a/ffplayout/ffplayout/settings/common.py b/ffplayout/ffplayout/settings/common.py index ae115741..50a1b5bf 100644 --- a/ffplayout/ffplayout/settings/common.py +++ b/ffplayout/ffplayout/settings/common.py @@ -120,12 +120,13 @@ for dir in os.listdir(APPS_DIR): # add app to installed apps INSTALLED_APPS += (app_name, ) - if os.path.isfile(os.path.join(APPS_DIR, dir, 'db.py')): - db_conn = locate('{}.db.Connector.config'.format(app_name)) + if os.path.isfile(os.path.join(APPS_DIR, dir, 'settings.py')): + db = locate('{}.settings.DATABASES'.format(app_name)) - if list(db_conn.keys())[0] not in DATABASES: - # add app db to DATABASES - DATABASES.update(db_conn) + for key in db: + if key not in DATABASES: + # add app db to DATABASES + DATABASES.update({key: db[key]}) # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.0/howto/static-files/