Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/announcements/crud.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import logging
from datetime import datetime

import sqlalchemy

# from sqlalchemy import func
import database

# from announcements.models import Announcements


async def create_new_entry(
db_session: database.DBSession,
title: str,
content: str,
computing_id: str,
date_created: datetime,
):
"""To create a new announcement entry"""

# TODO: Implement the logic to create a new announcement entry in the database
19 changes: 19 additions & 0 deletions src/announcements/tables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from sqlalchemy import DATETIME, INTEGER, VARCHAR, Column, ForeignKey

from constants import COMPUTING_ID_LEN
from database import Base
from officers import tables


class Announcement(Base):
__tablename__ = "announcements"

aid = Column(INTEGER, primary_key=True, autoincrement=True)
title = Column(VARCHAR(128), nullable=False)
content = Column(VARCHAR(256), nullable=False)
date_created = Column(DATETIME(timezone=True), nullable=False)
computing_id = Column(
VARCHAR(COMPUTING_ID_LEN),
ForeignKey("officer_info.computing_id"),
nullable=False,
)
23 changes: 23 additions & 0 deletions src/announcements/url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import logging

from fastapi import APIRouter, HTTPException, Request, status
from fastapi.responses import JSONResponse

import announcements.crud
import auth
import database
from permission.types import OfficerPrivateInfo

_logger = logging.getLogger(__name__)

router = APIRouter(
prefix="/announcements",
tags=["announcements"],
)

@router.get("",
response_class=JSONResponse,
status_code=status.HTTP_200_OK,
)
async def get_announcements(request: Request):
return {"message": "This is the announcements endpoint."}
Loading