Skip to content

Commit

Permalink
Fix phonebook : kinds enum and types file (#383)
Browse files Browse the repository at this point in the history
### Description

Please explain the changes you made here.

### Checklist

- [ ] Created tests which fail without the change (if possible)
- [ ] All tests passing
- [ ] Extended the documentation, if necessary
  • Loading branch information
Rotheem authored Mar 29, 2024
1 parent 7e34933 commit 88654b1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
8 changes: 4 additions & 4 deletions app/modules/phonebook/cruds_phonebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


# ---------------------------------------------------------------------------- #
Expand All @@ -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(";")
)


Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion app/modules/phonebook/models_phonebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion app/modules/phonebook/schemas_phonebook.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
File renamed without changes.
14 changes: 13 additions & 1 deletion migrations/versions/6-phonebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
)
Expand Down
3 changes: 1 addition & 2 deletions tests/test_phonebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 88654b1

Please sign in to comment.