mirror of
https://github.com/koloideal/DutyLog.git
synced 2026-06-10 10:25:29 +03:00
update
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user