From ac2c8675de5c3a2eea4aa2f6da9e5bb84ff8d2dd Mon Sep 17 00:00:00 2001 From: RezenkovD Date: Wed, 24 Jan 2024 21:13:08 +0200 Subject: [PATCH] feat: remove permissions to check group expenses inactive user --- src/services/group.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/services/group.py b/src/services/group.py index db73e6b..389791c 100644 --- a/src/services/group.py +++ b/src/services/group.py @@ -92,6 +92,21 @@ def group_member_validate_input_data( def read_group_history(db: Session, user_id: int, group_id: int) -> List[GroupHistory]: user_validate_input_date(db, user_id, group_id) + try: + ( + db.query(UserGroup) + .filter_by( + user_id=user_id, + group_id=group_id, + status=GroupStatusEnum.ACTIVE, + ) + .one() + ) + except exc.NoResultFound: + raise HTTPException( + status_code=status.HTTP_405_METHOD_NOT_ALLOWED, + detail="The user is not active in this group!", + ) history = ( select( Expense.id,