Skip to content

Commit

Permalink
Feat: refactoring base visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Rotheem committed Nov 27, 2024
1 parent 9010267 commit 89416d2
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 30 deletions.
4 changes: 2 additions & 2 deletions app/modules/advert/endpoints_advert.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sqlalchemy.ext.asyncio import AsyncSession

from app.core import models_core, standard_responses
from app.core.groups.groups_type import GroupType
from app.core.groups.groups_type import AccountType, GroupType
from app.core.notification.notification_types import CustomTopic, Topic
from app.core.notification.schemas_notification import Message
from app.dependencies import (
Expand All @@ -31,7 +31,7 @@
module = Module(
root="advert",
tag="Advert",
default_allowed_groups_ids=[GroupType.student, GroupType.staff],
default_allowed_account_types=[AccountType.student, AccountType.staff],
)

hyperion_error_logger = logging.getLogger("hyperion.error")
Expand Down
4 changes: 2 additions & 2 deletions app/modules/amap/endpoints_amap.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sqlalchemy.ext.asyncio import AsyncSession

from app.core import models_core, schemas_core
from app.core.groups.groups_type import GroupType
from app.core.groups.groups_type import AccountType, GroupType
from app.core.notification.notification_types import CustomTopic, Topic
from app.core.notification.schemas_notification import Message
from app.core.users import cruds_users
Expand All @@ -30,7 +30,7 @@
module = Module(
root="amap",
tag="AMAP",
default_allowed_groups_ids=[GroupType.student, GroupType.staff],
default_allowed_account_types=[AccountType.student, AccountType.staff],
)

hyperion_amap_logger = logging.getLogger("hyperion.amap")
Expand Down
4 changes: 2 additions & 2 deletions app/modules/booking/endpoints_booking.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from app.core import models_core
from app.core.groups import cruds_groups
from app.core.groups.groups_type import GroupType
from app.core.groups.groups_type import AccountType, GroupType
from app.core.notification.schemas_notification import Message
from app.dependencies import (
get_db,
Expand All @@ -25,7 +25,7 @@
module = Module(
root="booking",
tag="Booking",
default_allowed_groups_ids=[GroupType.student, GroupType.staff],
default_allowed_account_types=[AccountType.student, AccountType.staff],
)

hyperion_error_logger = logging.getLogger("hyperion.error")
Expand Down
4 changes: 2 additions & 2 deletions app/modules/calendar/endpoints_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sqlalchemy.ext.asyncio import AsyncSession

from app.core import models_core
from app.core.groups.groups_type import GroupType
from app.core.groups.groups_type import AccountType, GroupType
from app.dependencies import get_db, is_user_a_member_of, is_user_an_ecl_member
from app.modules.calendar import cruds_calendar, models_calendar, schemas_calendar
from app.modules.calendar.types_calendar import Decision
Expand All @@ -16,7 +16,7 @@
module = Module(
root="event",
tag="Calendar",
default_allowed_groups_ids=[GroupType.student, GroupType.staff],
default_allowed_account_types=[AccountType.student, AccountType.staff],
)

ical_file_path = "data/ics/ae_calendar.ics"
Expand Down
4 changes: 2 additions & 2 deletions app/modules/centralisation/endpoints_centralisation.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from app.core.groups.groups_type import GroupType
from app.core.groups.groups_type import AccountType
from app.types.module import Module

module = Module(
root="centralisation",
tag="Centralisation",
default_allowed_groups_ids=[GroupType.student, GroupType.staff],
default_allowed_account_types=[AccountType.student, AccountType.staff],
)
4 changes: 2 additions & 2 deletions app/modules/cinema/endpoints_cinema.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from app.core import models_core, standard_responses
from app.core.config import Settings
from app.core.groups.groups_type import GroupType
from app.core.groups.groups_type import AccountType, GroupType
from app.core.notification.notification_types import CustomTopic, Topic
from app.core.notification.schemas_notification import Message
from app.dependencies import (
Expand All @@ -34,7 +34,7 @@
module = Module(
root="cinema",
tag="Cinema",
default_allowed_groups_ids=[GroupType.student, GroupType.staff],
default_allowed_account_types=[AccountType.student, AccountType.staff],
)

hyperion_error_logger = logging.getLogger("hyperion.error")
Expand Down
4 changes: 2 additions & 2 deletions app/modules/flappybird/endpoints_flappybird.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.core.groups.groups_type import GroupType
from app.core.groups.groups_type import AccountType, GroupType
from app.dependencies import get_db, is_user_a_member, is_user_a_member_of
from app.modules.flappybird import (
cruds_flappybird,
Expand All @@ -17,7 +17,7 @@
module = Module(
root="flappybird",
tag="Flappy Bird",
default_allowed_groups_ids=[GroupType.student],
default_allowed_account_types=[AccountType.student],
)


Expand Down
4 changes: 2 additions & 2 deletions app/modules/home/endpoints_home.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from app.core.groups.groups_type import GroupType
from app.core.groups.groups_type import AccountType
from app.types.module import Module

module = Module(
root="home",
tag="Home",
default_allowed_groups_ids=[GroupType.student, GroupType.staff],
default_allowed_account_types=[AccountType.student, AccountType.staff],
)
4 changes: 2 additions & 2 deletions app/modules/loan/endpoints_loan.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sqlalchemy.ext.asyncio import AsyncSession

from app.core import models_core
from app.core.groups.groups_type import GroupType
from app.core.groups.groups_type import AccountType, GroupType
from app.core.notification.schemas_notification import Message
from app.dependencies import (
get_db,
Expand All @@ -31,7 +31,7 @@
module = Module(
root="loan",
tag="Loans",
default_allowed_groups_ids=[GroupType.student, GroupType.staff],
default_allowed_account_types=[AccountType.student, AccountType.staff],
)


Expand Down
4 changes: 2 additions & 2 deletions app/modules/ph/endpoints_ph.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sqlalchemy.ext.asyncio import AsyncSession

from app.core import models_core
from app.core.groups.groups_type import GroupType
from app.core.groups.groups_type import AccountType, GroupType
from app.core.notification.notification_types import CustomTopic, Topic
from app.core.notification.schemas_notification import Message
from app.dependencies import (
Expand All @@ -30,7 +30,7 @@
module = Module(
root="ph",
tag="ph",
default_allowed_groups_ids=[GroupType.student],
default_allowed_account_types=[AccountType.student],
)


Expand Down
4 changes: 2 additions & 2 deletions app/modules/phonebook/endpoints_phonebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from app.core import models_core, standard_responses
from app.core.groups import cruds_groups
from app.core.groups.groups_type import GroupType
from app.core.groups.groups_type import AccountType, GroupType
from app.core.users import cruds_users
from app.dependencies import (
get_db,
Expand All @@ -28,7 +28,7 @@
module = Module(
root="phonebook",
tag="Phonebook",
default_allowed_groups_ids=[GroupType.student, GroupType.staff],
default_allowed_account_types=[AccountType.student, AccountType.staff],
)

hyperion_error_logger = logging.getLogger("hyperion.error")
Expand Down
4 changes: 2 additions & 2 deletions app/modules/raffle/endpoints_raffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from app.core import models_core, standard_responses
from app.core.groups import cruds_groups
from app.core.groups.groups_type import GroupType
from app.core.groups.groups_type import AccountType, GroupType
from app.core.users import cruds_users
from app.core.users.endpoints_users import read_user
from app.dependencies import (
Expand All @@ -33,7 +33,7 @@
module = Module(
root="tombola",
tag="Raffle",
default_allowed_groups_ids=[GroupType.student, GroupType.staff],
default_allowed_account_types=[AccountType.student, AccountType.staff],
)

hyperion_raffle_logger = logging.getLogger("hyperion.raffle")
Expand Down
4 changes: 2 additions & 2 deletions app/modules/raid/endpoints_raid.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from app.core import models_core, schemas_core
from app.core.config import Settings
from app.core.google_api.google_api import DriveGoogleAPI
from app.core.groups.groups_type import GroupType
from app.core.groups.groups_type import AccountType, GroupType
from app.core.payment.payment_tool import PaymentTool
from app.dependencies import (
get_db,
Expand Down Expand Up @@ -48,7 +48,7 @@
root="raid",
tag="Raid",
payment_callback=validate_payment,
default_allowed_groups_ids=[GroupType.student, GroupType.staff],
default_allowed_account_types=[AccountType.student, AccountType.staff],
)


Expand Down
4 changes: 2 additions & 2 deletions app/modules/recommendation/endpoints_recommendation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sqlalchemy.ext.asyncio import AsyncSession

from app.core import models_core, standard_responses
from app.core.groups.groups_type import GroupType
from app.core.groups.groups_type import AccountType, GroupType
from app.dependencies import (
get_db,
get_request_id,
Expand All @@ -28,7 +28,7 @@
module = Module(
root="recommendation",
tag="Recommendation",
default_allowed_groups_ids=[GroupType.student, GroupType.staff],
default_allowed_account_types=[AccountType.student, AccountType.staff],
)


Expand Down
6 changes: 4 additions & 2 deletions app/types/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from fastapi import APIRouter
from sqlalchemy.ext.asyncio import AsyncSession

from app.core.groups.groups_type import GroupType
from app.core.groups.groups_type import AccountType, GroupType
from app.core.payment import schemas_payment


Expand All @@ -12,7 +12,8 @@ def __init__(
self,
root: str,
tag: str,
default_allowed_groups_ids: list[GroupType],
default_allowed_groups_ids: list[GroupType] | None = None,
default_allowed_account_types: list[AccountType] | None = None,
router: APIRouter | None = None,
payment_callback: Callable[
[schemas_payment.CheckoutPayment, AsyncSession],
Expand All @@ -29,6 +30,7 @@ def __init__(
"""
self.root = root
self.default_allowed_groups_ids = default_allowed_groups_ids
self.default_allowed_account_types = default_allowed_account_types
self.router = router or APIRouter(tags=[tag])
self.payment_callback: (
Callable[[schemas_payment.CheckoutPayment, AsyncSession], Awaitable[None]]
Expand Down

0 comments on commit 89416d2

Please sign in to comment.