Implement Veto Mode
This commit is contained in:
@@ -5,7 +5,7 @@ from sqlalchemy.orm import Session
|
||||
import app.models as models
|
||||
from app.database import get_db
|
||||
from app.schemas import Song
|
||||
from app.crud import get_songs_and_vote_for_session, create_or_update_vote, get_all_songs_and_votes
|
||||
from app.crud import get_songs_and_vote_for_session, create_or_update_vote, get_all_songs_and_votes, create_or_update_comment
|
||||
|
||||
router = APIRouter(
|
||||
prefix="/songs",
|
||||
@@ -16,13 +16,17 @@ router = APIRouter(
|
||||
|
||||
@router.get("/")
|
||||
async def get_songs(session_id: str = "", db: Annotated[Session, Depends(get_db)] = None) -> list[Song]:
|
||||
return [Song(**s.__dict__, vote=v) for s, v in get_songs_and_vote_for_session(db, session_id)]
|
||||
return [Song(**s.__dict__, vote=v, vote_comment=c) for s, v, c in get_songs_and_vote_for_session(db, session_id)]
|
||||
|
||||
|
||||
@router.post("/{song_id}/vote")
|
||||
async def vote(song_id: str, session_id: str, vote: int, db: Annotated[Session, Depends(get_db)]):
|
||||
create_or_update_vote(db, song_id, session_id, vote)
|
||||
|
||||
@router.post("/{song_id}/comment")
|
||||
async def comment(song_id: str, session_id: str, comment: str, db: Annotated[Session, Depends(get_db)]):
|
||||
create_or_update_comment(db, song_id, session_id, comment)
|
||||
#create_or_update_vote(db, song_id, session_id, vote)
|
||||
|
||||
@router.get("/evaluation")
|
||||
async def get_evaluation(db: Annotated[Session, Depends(get_db)] = None) -> dict[int, dict[int, int]]:
|
||||
|
||||
Reference in New Issue
Block a user