Skip to content

Commit 6150f61

Browse files
committed
chore: update to fastapi
never mind, it can't be done properly for now dropping this
1 parent 9933fc6 commit 6150f61

19 files changed

+108
-65
lines changed

INSTALL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Install
12

23
## Install using Docker
34

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ You certainly want to apply the database migrations with:
2828
./docker/migrate.sh
2929

3030

31-
3231
## Run the tests
3332

3433
./docker/test.sh

app/crud.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def _check_if_ref_exists(db: Session, ref: str):
227227

228228

229229
def create_election(
230-
db: Session, election: schemas.ElectionCreate
230+
db: Session, election: schemas.ElectionCreate,
231231
) -> schemas.ElectionGet:
232232
# We create first the election
233233
# without candidates and grades
@@ -236,7 +236,7 @@ def create_election(
236236
raise errors.InconsistentDatabaseError("Can not create election")
237237
election_ref = str(db_election.ref)
238238

239-
# Then, we add separatly candidates and grades
239+
# Then, we add separately candidates and grades
240240
for candidate in election.candidates:
241241
params = candidate.model_dump()
242242
candidate = schemas.CandidateCreate(**params)

app/database.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from __future__ import annotations
2+
3+
from contextvars import ContextVar
24
from urllib.parse import quote
35
from sqlalchemy import create_engine
4-
from sqlalchemy.orm import sessionmaker, declarative_base
6+
from sqlalchemy.orm import sessionmaker, declarative_base, Session
57
from .settings import settings
68

79

@@ -19,7 +21,7 @@
1921
engine = create_engine(database_url)
2022

2123
SessionLocal: sessionmaker = sessionmaker( # type: ignore
22-
autocommit=False, autoflush=False, bind=engine
24+
autocommit=False, autoflush=False, bind=engine,
2325
)
2426

2527
Base = declarative_base()
@@ -31,3 +33,5 @@ def get_db():
3133
yield db
3234
finally:
3335
db.close()
36+
37+
db_session: ContextVar[Session] = ContextVar('db_session')

app/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ async def inconsistent_database_exception_handler(
7777
return JSONResponse(
7878
status_code=500,
7979
content={
80-
"message": f"A serious error has occured with {exc.name}. {exc.details or ''}"
80+
"message": f"A serious error has occurred with {exc.name}. {exc.details or ''}"
8181
},
8282
)
8383

app/settings.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
from pydantic_settings import BaseSettings, SettingsConfigDict
44

55
class Settings(BaseSettings):
6-
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
6+
model_config = SettingsConfigDict(
7+
env_file=".env.local",
8+
extra="ignore",
9+
)
710

811
sqlite: bool = False
912

election/models.py

Whitespace-only changes.

election/serializers.py

Whitespace-only changes.

election/urls.py

Whitespace-only changes.

election/views.py

Whitespace-only changes.

0 commit comments

Comments
 (0)