update models to use string type for id fields
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
from uuid import UUID
|
||||
|
||||
from fastapi import APIRouter, Request
|
||||
from fastapi.templating import Jinja2Templates
|
||||
|
||||
from src.apis.utils import SessionDep
|
||||
from src.db.models.comic import Comic, Artist, Publisher
|
||||
from typing import AnyStr
|
||||
|
||||
templates = Jinja2Templates(directory="src/templates")
|
||||
router = APIRouter(include_in_schema=False, prefix="/comic")
|
||||
@@ -15,7 +13,7 @@ def get_comics(db: SessionDep, request: Request, msg: str = None):
|
||||
return templates.TemplateResponse("comic/comics.html", {"request": request, "msg": msg, "comics": comics})
|
||||
|
||||
@router.get("/comics/{comic_id}")
|
||||
def comic_details(comic_id: UUID, request: Request, db: SessionDep):
|
||||
def comic_details(comic_id: AnyStr, request: Request, db: SessionDep):
|
||||
comic = db.get(Comic, comic_id)
|
||||
return templates.TemplateResponse("comic/comic_detail.html", {"request": request, "comic":comic})
|
||||
|
||||
@@ -25,8 +23,8 @@ def get_artists(db: SessionDep, request: Request, msg: str = None):
|
||||
return templates.TemplateResponse("comic/artists.html", {"request": request, "msg": msg, "artists": artists})
|
||||
|
||||
@router.get("/artists/{artist_id}")
|
||||
def artist_detail(artist_id: UUID, request: Request, db: SessionDep):
|
||||
artist = db.get(Artist, artist_id)
|
||||
def artist_detail(artist_id: AnyStr, request: Request, db: SessionDep):
|
||||
artist = db.get(Artist, str(artist_id))
|
||||
return templates.TemplateResponse("comic/artist_detail.html", {"request": request, "artist": artist})
|
||||
|
||||
@router.get("/publishers")
|
||||
@@ -35,7 +33,7 @@ def get_publishers(db: SessionDep, request: Request, msg: str = None):
|
||||
return templates.TemplateResponse("comic/publishers.html", {"request": request, "publishers": publishers})
|
||||
|
||||
@router.get("/publishers/{publisher_id}")
|
||||
def publisher_details(publisher_id: UUID, request: Request, db: SessionDep, msg: str = None):
|
||||
def publisher_details(publisher_id: AnyStr, request: Request, db: SessionDep, msg: str = None):
|
||||
publisher = db.get(Publisher, publisher_id)
|
||||
if publisher is None:
|
||||
msg = "Could not find Publisher"
|
||||
|
||||
Reference in New Issue
Block a user