-
Notifications
You must be signed in to change notification settings - Fork 1
Добавил эндпоинт для удаления rental session #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
💩 Code linting failed, use |
|
Проверку на правильность удаления сессий и страйков протестил |
| RentalSession.query(session=db.session) | ||
| .filter(RentalSession.status == RentStatus.ACTIVE) | ||
| .filter(RentalSession.deadline_ts < datetime.datetime.now(tz=datetime.timezone.utc)) | ||
| .filter(RentalSession.is_deleted == False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не нужно
| exist_session_item: list[RentalSession] = ( | ||
| RentalSession.query(session=db.session) | ||
| .filter(RentalSession.user_id == user.get("id"), RentalSession.item_type_id == item_type_id) | ||
| .filter(RentalSession.is_deleted == False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не нужно
| session = RentalSession.get(id=session_id, session=db.session) | ||
| if not session: | ||
| raise ObjectNotFound(RentalSession, session_id) | ||
| if session.status == RentStatus.ACTIVE or session.status == RentStatus.RESERVED: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overdue
| if not session: | ||
| raise ObjectNotFound(RentalSession, session_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не нужно
| raise ForbiddenAction(RentalSession) | ||
| RentalSession.delete(id=session_id, session=db.session) | ||
| return StatusResponseModel( | ||
| status="Success", message="Rental session has been deleted", ru="Сессия удалена из RentalAPI" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- id сессии
Изменения
При удалении item идет проверка на наличие сессий не являющихся активными, зарезервированными, просроченными, если такие есть то они происходит софт делит для сессий и их страйков, также удаляются events^ связанные с сессиями.
Детали реализации
В модели бд ничего не менял, так как любые доп функции для поля там работают только при хард делитах, которые мы не поддерживаем.
Check-List
Тесты падают уже давно, надо будет стажерам дать их исправить)))
blackиisortдля Back-End илиPrettierдля Front-End?