Skip to content

Commit e9e65d4

Browse files
committed
initial commit for announcements module
1 parent 9b82525 commit e9e65d4

3 files changed

Lines changed: 61 additions & 0 deletions

File tree

src/announcements/crud.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import logging
2+
from datetime import date, datetime
3+
4+
import sqlalchemy
5+
from sqlalchemy import func
6+
7+
import database
8+
from announcements.models import Announcements
9+
10+
async def create_new_entry(
11+
db_session: database.DBSession,
12+
title: str,
13+
content: str,
14+
computing_id: str,
15+
date_created: date,
16+
):
17+
"""To create a new announcement entry"""
18+
19+
# TODO: Implement the logic to create a new announcement entry in the database
20+
pass

src/announcements/tables.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from sqlalchemy import Column, VARCHAR, INTEGER, DATETIME, ForeignKey
2+
3+
from constants import COMPUTING_ID_LEN
4+
from database import Base
5+
from officers import tables
6+
7+
class Announcement(Base):
8+
__tablename__ = "announcements"
9+
10+
aid = Column(INTEGER, primary_key=True, autoincrement=True)
11+
title = Column(VARCHAR(128), nullable=False)
12+
content = Column(VARCHAR(256), nullable=False)
13+
date_created = Column(DATETIME(timezone=True), nullable=False)
14+
computing_id = Column(
15+
VARCHAR(COMPUTING_ID_LEN),
16+
ForeignKey("officer_info.computing_id"),
17+
nullable=False,
18+
)

src/announcements/url.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import logging
2+
3+
from fastapi import APIRouter, Request, HTTPException, status
4+
import fastapi.responses import JSONResponse
5+
6+
import auth
7+
import announcements.crud
8+
import database
9+
from permission.types import OfficerPrivateInfo
10+
11+
_logger = logging.getLogger(__name__)
12+
13+
router = APIRouter(
14+
prefix="/announcements",
15+
tags=["announcements"],
16+
)
17+
18+
@router.get("",
19+
response_class=JSONResponse,
20+
status_code=status.HTTP_200_OK,
21+
)
22+
async def get_announcements(request: Request):
23+
return {"message": "This is the announcements endpoint."}

0 commit comments

Comments
 (0)