"""Coach-mode screens (C1-C6) -- design_handoff_rosterchief_platform/README.md's "Coach mode (mobile, dark chrome)" section. Kept separate from mobile/views.py (Member mode, M1-M7) since the two modes share almost no view logic beyond the club/season plumbing already factored into club.services.access -- see mobile/coach_mixins.py's CoachScopeMixin for the shared scaffolding. """ import datetime import re from django import forms from django.contrib.auth.mixins import LoginRequiredMixin from django.db.models import Case, F, Q, When from django.http import Http404, HttpResponseForbidden, HttpResponseRedirect from django.shortcuts import get_object_or_404, render from django.urls import reverse from django.utils import timezone from django.utils.dateparse import parse_datetime from django.utils.translation import gettext_lazy as _ from django.utils.translation import ngettext from django.views.generic import TemplateView, View from club.models import Season from club.services.access import can_add_news, current_season from controlpanel.messages import notify from events.models import Attendance, Event, EventSeries, Lineup, LineupSelection, Location, Opponent from events.services import generate_occurrences from events.services.attendance import member_attendance_counts, player_attendance_rankings, record_check_in from events.services.calendar import agenda_groups from events.services.lineup import UNAVAILABLE_STATUSES, cancel_scheduled_publish, publish_lineup, schedule_lineup_publish, toggle_selection from events.tasks import notify_new_event from management.forms import EventForm, EventSeriesForm, LocationForm, NewsForm, NewsPhotoUploadForm, OpponentForm from members.models import Member from news.models import News, NewsPhoto from news.services import notify_editors_of_pending_review from notifications.services import notify_members from teams.models import Position, StaffAssignment, Team, TeamMembership from teams.services import eligible_roster_members from .coach_mixins import CoachScopeMixin from .forms import _INPUT_CLASSES, _TEXTAREA_CLASSES, CoachRosterEditForm #: RSVP states that count as "in" for the stat tile -- present/selected are an #: explicit yes, maybe is still a lean-in rather than silence. IN_STATUSES = [Attendance.AttendanceStatus.PRESENT, Attendance.AttendanceStatus.SELECTED, Attendance.AttendanceStatus.MAYBE] #: An explicit no -- declined or, for a published line-up, not selected. #: Distinct from NO_RESPONSE ("silent"), which is a non-answer rather than a no. OUT_STATUSES = [Attendance.AttendanceStatus.ABSENT, Attendance.AttendanceStatus.EXCUSED, Attendance.AttendanceStatus.NOT_SELECTED] #: The event kinds CoachCreateEventView's tile picker offers -- social/other #: stay desktop-only (management.forms.EventForm keeps the full list), since #: neither has a tile here. COACH_EVENT_KINDS = [Event.EventKind.TRAINING, Event.EventKind.GAME, Event.EventKind.TOURNAMENT, Event.EventKind.MEETING] class _LocationPickerForm(forms.Form): """Just the ``location`` picker, standalone from EventForm/EventSeriesForm -- CoachCreateEventView's own field (same name, so it POSTs into whichever of those two forms actually validates the request) and CoachLocationCreateView's "+ New location" popup both render this same one, so a freshly created Location can be handed back pre-selected without reconstructing the much bigger surrounding form just to redraw one