Kaynağa Gözat

feat: implement commission enpoints and refactor auth tests

clovis 1 hafta önce
ebeveyn
işleme
cf8849a81e

+ 31 - 18
Readme.md

@@ -1,42 +1,55 @@
 # bdlg-2023-server
 
-This repository host an API that can parse gsheet planning for brass dans la garonne event and manage creating automatic SMS notification for volunteer.
+This repository host an API that can parse gsheet planning for brass dans la garonne event and manage creating automatic
+SMS notification for volunteer.
 
 ## Getting started
 
 For running the application
 
-> git clone ...
-> cd ...
-
-> python -m venv venv
-> venv/scripts/activate
-> poetry install
+```bash 
+git clone ...
+cd ...
+python -m venv venv
+venv/scripts/activate
+poetry install
+```
 
 Note, be sure to use python3.11 with this application
 
-> Copy .env.example to .env and edit it to configure your setup
-> init.sh
-> uvicorn app.main:app --reload
+* Copy .env.example to .env and edit it to configure your setup
+
+```bash
+init.sh
+uvicorn app.main:app --reload
+```
 
 ## Debug
 
-> python -m app.debug
+```bash 
+python -m app.debug
+```
 
 Run tests
 
-> pytest
+```bash 
+pytest
+pytest app\test\test_volunteer.py
+```
 
-Run specific tests
+Run coverage tests
 
-> pytest app\test\test_volunteer.py
+```bash 
+coverage run -m pytest
+coverage html
+```
 
 ## Update requirements
 
-```
-> poetry lock
-> poetry export -f requirements.txt --output requirements.txt --without-hashes
-> poetry export -f requirements.txt --output requirements-dev.txt --without-hashes --with dev
+```bash
+poetry lock
+poetry export -f requirements.txt --output requirements.txt --without-hashes
+oetry export -f requirements.txt --output requirements-dev.txt --without-hashes --with dev
 ```
 
 ## Credit

+ 36 - 0
alembic/versions/2026072549_add_timestamp_to_commission_b9072f955a8d.py

@@ -0,0 +1,36 @@
+"""add timestamp to commission
+
+Revision ID: b9072f955a8d
+Revises: f5fc28123cc0
+Create Date: 2026-07-25 09:49:34.418158
+
+"""
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects import postgresql
+
+# revision identifiers, used by Alembic.
+revision = 'b9072f955a8d'
+down_revision = 'f5fc28123cc0'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.add_column('commissions', sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False))
+    op.add_column('commissions', sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False))
+    op.alter_column('volunteer_groups', 'updated_at',
+               existing_type=postgresql.TIMESTAMP(timezone=True),
+               nullable=False)
+    # ### end Alembic commands ###
+
+
+def downgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.alter_column('volunteer_groups', 'updated_at',
+               existing_type=postgresql.TIMESTAMP(timezone=True),
+               nullable=True)
+    op.drop_column('commissions', 'updated_at')
+    op.drop_column('commissions', 'created_at')
+    # ### end Alembic commands ###

+ 0 - 8
app/api/deps.py

@@ -114,14 +114,6 @@ def require_org_role(*allowed_roles: OrgRole):
     return dependency
 
 
-def require_commission_membership():
-    """For CREATE endpoints (template/slot): confirms org membership only.
-    The finer 'does this respo_commission own the commission_id in the
-    payload' check happens inside the handler via assert_commission_ownership,
-    since the dependency layer can't see the parsed body cheaply."""
-    return require_org_role(OrgRole.ORG_ADMIN, OrgRole.RESPO_BENEVOLE, OrgRole.RESPO_COMMISSION)
-
-
 def assert_commission_ownership(
     session: Session, current_user: User, project_id: UUID, commission_id: str | None
 ) -> None: