Skip to content

Commit

Permalink
feat: Workspace 145 (#138)
Browse files Browse the repository at this point in the history
* new database connection function

* default to service name

* install psycopg2 binary

* don't pass in base dir

* use new pipeline

* use db as default name

* default back to service name

* install migration fixes

* fixed token field

* new RR version

* use main

* simplify

* regenerate migrations
  • Loading branch information
SKairinos authored Sep 27, 2024
1 parent f1383dd commit c749c7c
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 65 deletions.
3 changes: 2 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ django-cors-headers = "==4.1.0"
django-csp = "==3.7"
django-import-export = "==4.0.3"
pyotp = "==2.9.0"
psycopg2-binary = "==2.9.9"
requests = "==2.32.2"
importlib-metadata = "==4.13.0" # TODO: remove. needed by old portal
django-formtools = "==2.2" # TODO: remove. needed by old portal
django-otp = "==1.0.2" # TODO: remove. needed by old portal
# https://pypi.org/user/codeforlife/
cfl-common = "==7.3.3" # TODO: remove
codeforlife-portal = "==7.3.3" # TODO: remove
rapid-router = "==6.5.2" # TODO: remove
rapid-router = "==6.5.3" # TODO: remove
phonenumbers = "==8.12.12" # TODO: remove

[dev-packages]
Expand Down
172 changes: 132 additions & 40 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 10 additions & 17 deletions codeforlife/settings/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,17 @@
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases


def get_databases(base_dir: Path): # pragma: no cover
"""Get the databases for the Django project.
Args:
base_dir: The base directory of the Django project.
Returns:
The databases for the django project.
"""
return {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": base_dir / "db.sqlite3",
"ATOMIC_REQUESTS": True,
}
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": os.getenv("DB_NAME", SERVICE_NAME),
"HOST": os.getenv("DB_HOST", "localhost"),
"PORT": int(os.getenv("DB_PORT", "5432")),
"USER": os.getenv("DB_USER", "root"),
"PASSWORD": os.getenv("DB_PASSWORD", "password"),
"ATOMIC_REQUESTS": True,
}

}

# Application definition

Expand Down
2 changes: 1 addition & 1 deletion codeforlife/user/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.2.25 on 2024-09-27 10:06
# Generated by Django 3.2.25 on 2024-09-27 15:24

import codeforlife.user.models.user
import django.contrib.auth.models
Expand Down
6 changes: 0 additions & 6 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
This file manages Django but also acts a settings file.
"""

from pathlib import Path

# pylint: disable-next=wildcard-import,unused-wildcard-import
from codeforlife.settings import *

BASE_DIR = Path(__file__).resolve().parent

INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
Expand All @@ -34,8 +30,6 @@

ROOT_URLCONF = "codeforlife.user.urls"

DATABASES = get_databases(BASE_DIR)

if __name__ == "__main__":
import os
import sys
Expand Down

0 comments on commit c749c7c

Please sign in to comment.