initial commit

This commit is contained in:
Lucas Jensen
2024-05-01 09:19:01 -07:00
commit 5d67c0c2b2
117 changed files with 9917 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
from fastapi import HTTPException, status
from app.controllers.base_controller import BaseController
from app.db import group_queries
from app.db.group import GroupQueries
from app.models.group import Group
class GroupController(BaseController):
def __init__(self) -> None:
super().__init__()
self.db: GroupQueries = group_queries
async def get_group(self) -> Group:
if (data := await self.db.get_one()) is None:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND, detail="Group not found"
)
try:
return Group(**data)
except Exception as e:
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail=f"Error creating group object: {e}",
)
async def update_group_bio(self, bio: str) -> Group:
try:
await self.db.update_group_bio(bio)
except Exception as e:
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail=f"Error updating group bio: {e}",
)
return await self.get_group()