alternate schedule and template consistency (#2757)

* refactor classic and block schedules to use same alternate schedule selector

* handle start year and end year

* add migrations for classic and block schedules

* allow editing block template start and end year

* add tests that include years

* add date range editing to classic (alternate) schedules

* fix running tests locally

* restore media files load; needed for local folder scanners

* update changelog

* feedback
This commit is contained in:
Jason Dove
2026-01-06 12:51:07 -06:00
committed by GitHub
parent cc521326d9
commit effb96a2c2
40 changed files with 15366 additions and 736 deletions
@@ -7,10 +7,6 @@ namespace ErsatzTV.ViewModels;
public class PlayoutTemplateEditViewModel
{
private int _endDay;
private int _endMonth;
private int _startDay;
private int _startMonth;
public int Id { get; set; }
public int Index { get; set; }
public TemplateViewModel Template { get; set; }
@@ -25,28 +21,32 @@ public class PlayoutTemplateEditViewModel
public int StartMonth
{
get => _startMonth == 0 ? 1 : _startMonth;
set => _startMonth = value;
get => field == 0 ? 1 : field;
set;
}
public int StartDay
{
get => _startDay == 0 ? 1 : _startDay;
set => _startDay = value;
get => field == 0 ? 1 : field;
set;
}
public int? StartYear { get; set; }
public int EndMonth
{
get => _endMonth == 0 ? 12 : _endMonth;
set => _endMonth = value;
get => field == 0 ? 12 : field;
set;
}
public int EndDay
{
get => _endDay == 0 ? 31 : _endDay;
set => _endDay = value;
get => field == 0 ? 31 : field;
set;
}
public int? EndYear { get; set; }
public bool AppliesToDate(DateTime date)
{
// share the PlayoutTemplateSelector logic
@@ -59,16 +59,18 @@ public class PlayoutTemplateEditViewModel
LimitToDateRange = LimitToDateRange,
StartMonth = StartMonth,
StartDay = StartDay,
StartYear = StartYear,
EndMonth = EndMonth,
EndDay = EndDay
EndDay = EndDay,
EndYear = EndYear
};
TimeSpan offset = TimeZoneInfo.Local.GetUtcOffset(
new DateTime(date.Year, date.Month, date.Day, 0, 0, 0, DateTimeKind.Local));
Option<PlayoutTemplate> result =
PlayoutTemplateSelector.GetPlayoutTemplateFor(
new[] { template },
AlternateScheduleSelector.GetScheduleForDate(
[template],
new DateTimeOffset(
date.Year,
date.Month,