Consolidate WEEKEND_DAYS and fix weekday pickup button labels

Import WEEKEND_DAYS from shared.schedule instead of redefining in
blocks.py and weekly-post/app.py. Gate pickup button day/night
labels on weekends only, matching all other display surfaces.
This commit is contained in:
Adam Moussa 2026-05-12 19:34:01 -04:00
parent c3b35ed62e
commit cbf36b30ff
2 changed files with 6 additions and 8 deletions

View file

@ -3,9 +3,9 @@
from datetime import datetime, timedelta
from zoneinfo import ZoneInfo
EASTERN = ZoneInfo("America/New_York")
from shared.schedule import WEEKEND_DAYS
WEEKEND_DAYS = {"Saturday", "Sunday"}
EASTERN = ZoneInfo("America/New_York")
SHIFT_LABELS = {
@ -97,14 +97,15 @@ def build_week_schedule(schedule, start_date: datetime | None = None) -> list[di
elements = []
for date_str, shift_type in open_shifts:
dt = datetime.strptime(date_str, "%Y-%m-%d")
label = "Day" if shift_type == "day" else "Night"
day_name = dt.strftime("%A")
label = f" {SHIFT_LABELS[shift_type]}" if day_name in WEEKEND_DAYS else ""
action_suffix = "_day" if shift_type == "day" else ""
elements.append(
{
"type": "button",
"text": {
"type": "plain_text",
"text": f"Pick up {dt.strftime('%a %b %-d')} {label}",
"text": f"Pick up {dt.strftime('%a %b %-d')}{label}",
},
"action_id": f"pickup_{date_str}{action_suffix}",
"style": "primary",

View file

@ -11,7 +11,7 @@ import boto3
from slack_sdk import WebClient
from shared.blocks import build_pay_summary_blocks, build_week_schedule
from shared.schedule import FALLBACK_EXTENSION, ShiftSchedule
from shared.schedule import FALLBACK_EXTENSION, WEEKEND_DAYS, ShiftSchedule
from shared.secrets import get_secret
logger = logging.getLogger()
@ -30,9 +30,6 @@ DAY_ORDER = [
]
WEEKEND_DAYS = {"Saturday", "Sunday"}
def _add_shift_to_pay(schedule, breakdown, totals, date, day_name, shift_type="night"):
"""Resolve a shift and add it to the pay breakdown if assigned."""
date_str = date.strftime("%Y-%m-%d")