diff --git a/app/modules/phonebook/cruds_phonebook.py b/app/modules/phonebook/cruds_phonebook.py index 04031573d..d129b67ea 100644 --- a/app/modules/phonebook/cruds_phonebook.py +++ b/app/modules/phonebook/cruds_phonebook.py @@ -5,7 +5,7 @@ from sqlalchemy.ext.asyncio import AsyncSession from app.core import models_core -from app.modules.phonebook import models_phonebook, phonebook_types, schemas_phonebook +from app.modules.phonebook import models_phonebook, schemas_phonebook, types_phonebook # ---------------------------------------------------------------------------- # @@ -28,7 +28,7 @@ async def is_user_president( ) return ( membership is not None - and phonebook_types.RoleTags.president.value in membership.role_tags.split(";") + and types_phonebook.RoleTags.president.value in membership.role_tags.split(";") ) @@ -47,13 +47,13 @@ async def get_all_associations( async def get_all_role_tags() -> Sequence[str]: """Return all RoleTags from Enum""" - return [tag.value for tag in phonebook_types.RoleTags] + return [tag.value for tag in types_phonebook.RoleTags] async def get_all_kinds() -> Sequence[str]: """Return all Kinds from Enum""" - return [kind.value for kind in phonebook_types.Kinds] + return [kind.value for kind in types_phonebook.Kinds] async def get_all_memberships( diff --git a/app/modules/phonebook/models_phonebook.py b/app/modules/phonebook/models_phonebook.py index d86b9a0cc..cf4debdc4 100644 --- a/app/modules/phonebook/models_phonebook.py +++ b/app/modules/phonebook/models_phonebook.py @@ -2,7 +2,7 @@ from sqlalchemy.orm import Mapped, mapped_column from app.database import Base -from app.modules.phonebook.phonebook_types import Kinds +from app.modules.phonebook.types_phonebook import Kinds class Membership(Base): diff --git a/app/modules/phonebook/schemas_phonebook.py b/app/modules/phonebook/schemas_phonebook.py index 7b2d8dc73..5f33a6c1a 100644 --- a/app/modules/phonebook/schemas_phonebook.py +++ b/app/modules/phonebook/schemas_phonebook.py @@ -1,7 +1,7 @@ from pydantic import BaseModel, ConfigDict from app.core import schemas_core -from app.modules.phonebook.phonebook_types import Kinds +from app.modules.phonebook.types_phonebook import Kinds class RoleTagsReturn(BaseModel): diff --git a/app/modules/phonebook/phonebook_types.py b/app/modules/phonebook/types_phonebook.py similarity index 100% rename from app/modules/phonebook/phonebook_types.py rename to app/modules/phonebook/types_phonebook.py diff --git a/migrations/versions/6-phonebook.py b/migrations/versions/6-phonebook.py index 3dac8fafe..d2e058d19 100644 --- a/migrations/versions/6-phonebook.py +++ b/migrations/versions/6-phonebook.py @@ -25,7 +25,19 @@ def upgrade() -> None: sa.Column("id", sa.String(), nullable=False), sa.Column("name", sa.String(), nullable=False), sa.Column("description", sa.String(), nullable=True), - sa.Column("kind", sa.String(), nullable=False), + sa.Column( + "kind", + sa.Enum( + "Comité", + "Section AE", + "Club AE", + "Section USE", + "Club USE", + "Asso indé", + name="kinds", + ), + nullable=False, + ), sa.Column("mandate_year", sa.Integer(), nullable=False), sa.PrimaryKeyConstraint("id"), ) diff --git a/tests/test_phonebook.py b/tests/test_phonebook.py index bdc17ef54..fc4093c98 100644 --- a/tests/test_phonebook.py +++ b/tests/test_phonebook.py @@ -6,7 +6,7 @@ from app.core import models_core from app.core.groups.groups_type import GroupType from app.modules.phonebook import models_phonebook, schemas_phonebook -from app.modules.phonebook.phonebook_types import Kinds, RoleTags +from app.modules.phonebook.types_phonebook import Kinds, RoleTags from tests.commons import ( add_object_to_db, client, @@ -23,7 +23,6 @@ membership_to_delete_admin: models_phonebook.Membership | None = None membership_to_delete_president: models_phonebook.Membership | None = None membership_to_delete_simple: models_phonebook.Membership | None = None - phonebook_user_BDE: models_core.CoreUser | None = None phonebook_user_president: models_core.CoreUser | None = None phonebook_user_simple: models_core.CoreUser | None = None