Skip to content

Commit

Permalink
fix: A bunch of fixes for superday (for simplicity) (#23)
Browse files Browse the repository at this point in the history
* fix: A bunch of fixes for superday (for simplicity)

* move to ruff

* might as well clean this up

* Update runtests.py

Co-authored-by: ted kaemming <[email protected]>

* Update runtests.py

Co-authored-by: ted kaemming <[email protected]>

---------

Co-authored-by: ted kaemming <[email protected]>
  • Loading branch information
fuziontech and tkaemming authored Aug 31, 2024
1 parent 2790a81 commit bf1fa2c
Show file tree
Hide file tree
Showing 6 changed files with 11,959 additions and 20 deletions.
24 changes: 18 additions & 6 deletions backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"test" in sys.argv or sys.argv[0].endswith("pytest") or get_from_env("TEST", False, type_cast=str_to_bool)
) # type: bool

SUPERDAY = get_from_env("SUPERDAY", False, type_cast=str_to_bool)

ALLOWED_HOSTS: List[str] = get_list(os.getenv("ALLOWED_HOSTS", ""))


Expand Down Expand Up @@ -197,14 +199,24 @@
"TEST_REQUEST_DEFAULT_FORMAT": "json",
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination",
"PAGE_SIZE": 100,
"EXCEPTION_HANDLER": "exceptions_hog.exception_handler",
"DEFAULT_AUTHENTICATION_CLASSES": [
"EXCEPTION_HANDLER": "exceptions_hog.exception_handler"
}


# Authentication and permissions
# Disable auth if superday
if not SUPERDAY:
REST_FRAMEWORK["DEFAULT_AUTHENTICATION_CLASSES"] = [
"rest_framework.authentication.SessionAuthentication",
],
"DEFAULT_PERMISSION_CLASSES": [
]

REST_FRAMEWORK["DEFAULT_PERMISSION_CLASSES"] = [
"rest_framework.permissions.IsAuthenticated",
],
}
]
else:
REST_FRAMEWORK["DEFAULT_AUTHENTICATION_CLASSES"] = []
REST_FRAMEWORK["DEFAULT_PERMISSION_CLASSES"] = []


# CORS
# https://github.com/adamchainz/django-cors-headers
Expand Down
3 changes: 3 additions & 0 deletions backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def frontend(request, *args, **kwargs):


def login_required(view):
if settings.SUPERDAY:
return view

base_handler = base_login_required(view)

@wraps(view)
Expand Down
16 changes: 12 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: "3.4"
services:
postgres:
image: postgis/postgis:14-master
image: kartoza/postgis:16
restart: on-failure
environment:
POSTGRES_USER: whereintheworld
POSTGRES_PASSWORD: whereintheworld
POSTGRES_DB: whereintheworld
POSTGRES_PASS: whereintheworld
POSTGRES_DBNAME: whereintheworld
ports:
- "5433:5432"
app:
Expand All @@ -25,9 +25,11 @@ services:
SOCIAL_AUTH_GITHUB_KEY: $SOCIAL_AUTH_GITHUB_KEY
SOCIAL_AUTH_GITHUB_SECRET: $SOCIAL_AUTH_GITHUB_SECRET
MAPS_API_KEY: $MAPS_API_KEY
SUPERDAY: "1"
MULTI_TENANCY: "1"
ports:
- "8000:8000"
- "3000:3000"
links:
- "postgres:postgres"
depends_on:
Expand All @@ -39,7 +41,13 @@ services:
context: .
entrypoint: ["sh", "-c"]
command:
- python manage.py migrate
- |
echo "Waiting for postgres..."
while ! nc -z postgres 5432; do
sleep 0.1
done
echo "PostgreSQL started"
python manage.py migrate
depends_on:
postgres:
condition: service_started
Expand Down
Loading

0 comments on commit bf1fa2c

Please sign in to comment.