Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6794ec1
remove overcomplication, fix semantics, more DRY. For /all & /current
EarthenSky Dec 9, 2024
2751dec
remove comments, make names more consistent
EarthenSky Dec 9, 2024
1ecd0e1
small cleaning of crud functions
EarthenSky Dec 9, 2024
bd96ceb
clean up get officer info and get officer terms
EarthenSky Dec 10, 2024
dd5ffec
clean & fix POST /term
EarthenSky Dec 10, 2024
2e28910
clean PATCH /info function
EarthenSky Dec 10, 2024
e227437
clean final endpoint, PATCH /term
EarthenSky Dec 10, 2024
f3f59f2
add DELETE /term endpoint
EarthenSky Dec 10, 2024
1d12211
remove max_terms
EarthenSky Dec 10, 2024
47a05d0
small improvements to consistency
EarthenSky Dec 10, 2024
508f08e
fix and test delete term endpoint
EarthenSky Dec 12, 2024
67c9c5d
switch to using date instead of datetime for officer term + cleaning
EarthenSky Dec 12, 2024
ab924d3
fix test
EarthenSky Dec 12, 2024
69618b2
remove filled in function check
EarthenSky Dec 12, 2024
b679009
complete some TODOs
EarthenSky Dec 12, 2024
58f4d34
clean up some todos
EarthenSky Dec 12, 2024
c1f3888
update permissinos for /terms/{computing_id}
EarthenSky Dec 29, 2024
f45f464
allow changing computing_id by admins and add all TODOs
EarthenSky Dec 29, 2024
65733e6
remove tests backend endpoints (use fe instead please)
EarthenSky Dec 29, 2024
4d0131a
fix tests and add basic endpoint tests
EarthenSky Dec 29, 2024
eec4bd1
small bug fixes
EarthenSky Dec 29, 2024
e79afef
Update alembic.yml for python3.11
EarthenSky Dec 29, 2024
e084d6d
fix ansync test harness & fix small crud bug
EarthenSky Dec 29, 2024
7808436
more bug fixes & add integration tests
EarthenSky Dec 29, 2024
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
4 changes: 3 additions & 1 deletion .github/workflows/alembic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ jobs:

- name: Install dependencies
run: |
sudo apt-get install python3.11 python3.11-venv
# for python3.11 (dear internet gods: we'll update to 3.13 or something in a year, i promise)
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.11 python3.11-venv
python3.11 -m pip install --upgrade pip
python3.11 -m venv venv
source ./venv/bin/activate
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# major
fastapi==0.109.1
fastapi==0.115.6
gunicorn==21.2.0
uvicorn[standard]==0.27.1
sqlalchemy[asyncio]==2.0.27
Expand All @@ -19,3 +19,4 @@ ruff==0.6.9
# test
pytest
pytest-asyncio
httpx
4 changes: 2 additions & 2 deletions src/alembic/versions/166f3772fce7_auth_officer_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def upgrade() -> None:
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
sa.Column("computing_id", sa.String(length=32), sa.ForeignKey("site_user.computing_id"), nullable=False),
sa.Column("position", sa.String(length=128), nullable=False),
sa.Column("start_date", sa.DateTime(), nullable=False),
sa.Column("end_date", sa.DateTime(), nullable=True),
sa.Column("start_date", sa.Date(), nullable=False),
sa.Column("end_date", sa.Date(), nullable=True),
sa.Column("nickname", sa.String(length=128), nullable=True),
sa.Column("favourite_course_0", sa.String(length=32), nullable=True),
sa.Column("favourite_course_1", sa.String(length=32), nullable=True),
Expand Down
6 changes: 3 additions & 3 deletions src/cron/daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import google_api
import utils
from database import _db_session
from officers.crud import all_officer_data, get_user_by_username
from officers.crud import all_officers, get_user_by_username

_logger = logging.getLogger(__name__)

Expand All @@ -18,7 +18,7 @@ async def update_google_permissions(db_session):

# TODO: for performance, only include officers with recent end-date (1 yr)
# but measure performance first
for term in await all_officer_data(db_session):
for term in await all_officers(db_session):
if utils.is_active(term):
# TODO: if google drive permission is not active, update them
pass
Expand All @@ -31,7 +31,7 @@ async def update_google_permissions(db_session):
async def update_github_permissions(db_session):
github_permissions, team_id_map = github.all_permissions()

for term in await all_officer_data(db_session):
for term in await all_officers(db_session):
new_teams = (
# move all active officers to their respective teams
github.officer_teams(term.position)
Expand Down
42 changes: 21 additions & 21 deletions src/load_test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,9 @@ async def load_test_officers_data(db_session: AsyncSession):
))
await db_session.commit()

SYSADMIN_COMPUTING_ID = "gsa92"
async def load_sysadmin(db_session: AsyncSession):
# put your computing id here for testing purposes
SYSADMIN_COMPUTING_ID = "gsa92"

print(f"loading new sysadmin '{SYSADMIN_COMPUTING_ID}'")
await create_user_session(db_session, f"temp_id_{SYSADMIN_COMPUTING_ID}", SYSADMIN_COMPUTING_ID)
await create_new_officer_info(db_session, OfficerInfo(
Expand All @@ -232,28 +231,11 @@ async def load_sysadmin(db_session: AsyncSession):
await create_new_officer_term(db_session, OfficerTerm(
computing_id=SYSADMIN_COMPUTING_ID,

position=OfficerPosition.SYSTEM_ADMINISTRATOR,
start_date=date.today() - timedelta(days=365),
end_date=None,

nickname="Gabe",
favourite_course_0="CMPT 379",
favourite_course_1="CMPT 295",

favourite_pl_0="Rust",
favourite_pl_1="C",

biography="The systems are good o7",
photo_url=None,
))
await create_new_officer_term(db_session, OfficerTerm(
computing_id=SYSADMIN_COMPUTING_ID,

position=OfficerPosition.FIRST_YEAR_REPRESENTATIVE,
start_date=date.today() - timedelta(days=(365*3)),
end_date=date.today() - timedelta(days=(365*2)),

nickname="Gabe",
nickname="G1",
favourite_course_0="MACM 101",
favourite_course_1="CMPT 125",

Expand All @@ -270,7 +252,7 @@ async def load_sysadmin(db_session: AsyncSession):
start_date=date.today() - timedelta(days=365),
end_date=None,

nickname="Gabe",
nickname="G2",
favourite_course_0="CMPT 379",
favourite_course_1="CMPT 295",

Expand All @@ -280,6 +262,24 @@ async def load_sysadmin(db_session: AsyncSession):
biography="The systems are good o7",
photo_url=None,
))
# a future term
await create_new_officer_term(db_session, OfficerTerm(
computing_id=SYSADMIN_COMPUTING_ID,

position=OfficerPosition.DIRECTOR_OF_ARCHIVES,
start_date=date.today() + timedelta(days=365*1),
end_date=date.today() + timedelta(days=365*2),

nickname="G3",
favourite_course_0="MACM 102",
favourite_course_1="CMPT 127",

favourite_pl_0="C%",
favourite_pl_1="C$$",

biography="o hey fellow kids \n\n\n I will can newline .... !!",
photo_url=None,
))
await db_session.commit()

async def async_main(sessionmanager):
Expand Down
3 changes: 0 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import database
import officers.urls
import permission.urls
import tests.urls

logging.basicConfig(level=logging.DEBUG)
database.setup_database()
Expand All @@ -17,8 +16,6 @@
app.include_router(officers.urls.router)
app.include_router(permission.urls.router)

app.include_router(tests.urls.router)

@app.get("/")
async def read_root():
return {"message": "Hello! You might be lost, this is actually the sfucsss.org's backend api."}
10 changes: 4 additions & 6 deletions src/officers/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ def position_list() -> list[str]:

@staticmethod
def length_in_semesters(position: str) -> int | None:
# TODO: ask the committee to maintain a json file with all the important details from the constitution
# (I can create the version version of the file)
# TODO (#101): ask the committee to maintain a json file with all the important details from the constitution
"""How many semester position is active for, according to the CSSS Constitution"""
return _LENGTH_MAP[position]

Expand Down Expand Up @@ -71,6 +70,7 @@ def is_signer(position: str) -> bool:

@staticmethod
def expected_positions() -> list[str]:
# TODO (#93): use this function in the daily cronjobs
return [
OfficerPosition.PRESIDENT,
OfficerPosition.VICE_PRESIDENT,
Expand All @@ -81,11 +81,11 @@ def expected_positions() -> list[str]:
OfficerPosition.DIRECTOR_OF_EDUCATIONAL_EVENTS,
OfficerPosition.ASSISTANT_DIRECTOR_OF_EVENTS,
OfficerPosition.DIRECTOR_OF_COMMUNICATIONS,
#OfficerPosition.DIRECTOR_OF_OUTREACH, # TODO: when https://github.com/CSSS/documents/pull/9/files merged
#OfficerPosition.DIRECTOR_OF_OUTREACH, # TODO (#101): when https://github.com/CSSS/documents/pull/9/files merged
OfficerPosition.DIRECTOR_OF_MULTIMEDIA,
OfficerPosition.DIRECTOR_OF_ARCHIVES,
OfficerPosition.EXECUTIVE_AT_LARGE,
# TODO: expect these only during fall & spring semesters. Also, TODO: this todo is correct...
# TODO (#101): expect these only during fall & spring semesters.
#OfficerPosition.FIRST_YEAR_REPRESENTATIVE,

#ElectionsOfficer,
Expand Down Expand Up @@ -121,8 +121,6 @@ def expected_positions() -> list[str]:
OfficerPosition.SOCIAL_MEDIA_MANAGER: "N/A",
}

# TODO: when an officer's start date is modified, update the end date as well if it's defined in this list
# a number of semesters (a semester begins on the 1st of each four month period, starting january)
# None, means that the length of the position does not have a set length in semesters
_LENGTH_MAP = {
OfficerPosition.PRESIDENT: 3,
Expand Down
Loading
Loading