Feature/game training kind - #151
Conversation
Создание и редактирование игры теперь начинается с выбора: игра или тренировка. Тренеры бывают только у тренировки, поэтому их поля уехали под этот переключатель, и тренеров можно выбрать двух — каждый получает своё приглашение и отвечает на него сам. Приглашение, подтверждение дат, расписание тренера и напоминания работают для обоих слотов. Старые игры с тренером стали тренировками: тренер без тренировки не бывает и в обратную сторону. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Тренеров у тренировки бывает двое, и coach_accepted? теперь значит «принял хоть один». Право на рассылку ролика спрашиваем про конкретного человека, иначе первый тренер получал его по чужому согласию, а второй не получал по своему. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8639222cab
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| def authorize_coach! | ||
| head :forbidden unless @game.coach_accepted? && @game.coach == current_user | ||
| head :forbidden unless @game.accepted_coach?(current_user) |
There was a problem hiding this comment.
Scope prebooking deletion to the requesting coach
When a training has two accepted coaches, this authorization allows either coach into destroy, while that action finds the booking only through the game. A coach can therefore submit the other coach's booking ID and cancel their confirmation; scope the lookup to current_user or verify the booking's coach_id before deletion.
Useful? React with 👍 / 👎.
| invited_coaches = @game.coaches.reject { |coach| previous_coach_ids.include?(coach.id) } | ||
| invited_coaches.each { |coach| deliver_coach_invitation(coach) } |
There was a problem hiding this comment.
Re-invite coaches after moving them between slots
When existing coaches are swapped between the primary and secondary slots—or the secondary coach is promoted after clearing the primary—model normalization resets the moved coach's invitation status to pending. Because this filter compares only against the unordered set of previous IDs, it then excludes that coach from delivery, leaving them pending without a new invitation; detect per-slot changes or invite coaches whose status was newly reset.
Useful? React with 👍 / 👎.
Отмена подтверждённой даты теперь ищет бронь среди своих: у тренировки двух тренеров чужой id брони приходит тем же маршрутом, и второй тренер мог снять подтверждение первого. Приглашение уходит по смене слота, а не набора тренеров. Если тренеров поменять местами или поднять второго на место первого, модель сбрасывает статусы в pending — а по одному только набору id никто нового приглашения не получал и оба оставались висеть. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
No description provided.