From 1e9efd9cf3fb20db15ffb1a845eb6cb50bde77a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Tue, 6 Sep 2022 00:03:44 +0000 Subject: [PATCH] calendar + aggregate config --- api/ovdashboard_api/config.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/api/ovdashboard_api/config.py b/api/ovdashboard_api/config.py index db40bd5..5c21bb5 100644 --- a/api/ovdashboard_api/config.py +++ b/api/ovdashboard_api/config.py @@ -38,15 +38,24 @@ class ImageConfig(BaseModel): } -class AggregateCalendarConfig(BaseModel): +class CalAggregateConfig(BaseModel): """ - Sections "[[aggregate]]" in "config.txt". + Sections "[[calendar.aggregate]]" in "config.txt". """ name: str = "All Events" calendars: list[str] +class CalendarConfig(BaseModel): + """ + Section "[calendar]" in "config.txt". + """ + + future_days: int = 365 + aggregate: list[CalAggregateConfig] = [] + + class Config(BaseModel): """ Main representation of "config.txt". @@ -54,7 +63,7 @@ class Config(BaseModel): ticker: TickerConfig = TickerConfig() image: ImageConfig = ImageConfig() - aggregate: list[AggregateCalendarConfig] = [] + calendar: CalendarConfig = CalendarConfig() @classmethod async def get(cls) -> "Config": @@ -71,8 +80,8 @@ class Config(BaseModel): except RemoteResourceNotFound: cfg = cls() - cfg.aggregate.append( - AggregateCalendarConfig(calendars=await caldav_list()), + cfg.calendar.aggregate.append( + CalAggregateConfig(calendars=await caldav_list()), ) buffer = BytesIO()