This commit is contained in:
2026-03-18 09:22:50 +03:00
parent 993eb988e4
commit d307061669
3 changed files with 45 additions and 5 deletions
@@ -2,6 +2,7 @@ from dutylog.infrastructure.database.dao.hours_transactions_dao import (
HoursTransactionsDAO,
)
from dutylog.infrastructure.database.dao.residents_dao import ResidentsDAO
from dutylog.infrastructure.database.dao.users_dao import UsersDAO
from dutylog.infrastructure.database.models.hours_transaction import (
HoursTransaction,
TransactionType,
@@ -14,9 +15,11 @@ class HoursTransactionsRepository:
self,
transactions_dao: HoursTransactionsDAO,
residents_dao: ResidentsDAO,
users_dao: UsersDAO,
):
self.transactions_dao = transactions_dao
self.residents_dao = residents_dao
self.users_dao = users_dao
async def add_hours(
self,
@@ -143,6 +146,11 @@ class HoursTransactionsRepository:
results = []
for resident in residents:
if resident.is_busy and resident.user_entity:
user = await self.users_dao.get_by_id(resident.user_entity)
if user and user.is_admin:
continue
result = await self.add_hours(
resident_id=resident.id,
amount=amount,
+2 -1
View File
@@ -97,8 +97,9 @@ class RepositoryProvider(Provider):
self,
transactions_dao: HoursTransactionsDAO,
residents_dao: ResidentsDAO,
users_dao: UsersDAO,
) -> HoursTransactionsRepository:
return HoursTransactionsRepository(transactions_dao, residents_dao)
return HoursTransactionsRepository(transactions_dao, residents_dao, users_dao)
@provide(scope=Scope.REQUEST)
def get_rooms_repository(self, rooms_dao: RoomsDAO) -> RoomsRepository: