From 8c9d6bc6eff413476fa75bf5b6d995a72b028fff Mon Sep 17 00:00:00 2001 From: Tiago Scholten Date: Sun, 11 Oct 2026 22:10:58 +0200 Subject: [PATCH] Started working on events/activities based on Florians work --- src/fiber_package/events/activity.py | 25 ++++++++++++ src/fiber_package/events/communication.py | 46 +++++++++++++++++++++++ src/fiber_package/events/enums.py | 10 +++++ 3 files changed, 81 insertions(+) create mode 100644 src/fiber_package/events/activity.py create mode 100644 src/fiber_package/events/communication.py create mode 100644 src/fiber_package/events/enums.py diff --git a/src/fiber_package/events/activity.py b/src/fiber_package/events/activity.py new file mode 100644 index 0000000..bf63afa --- /dev/null +++ b/src/fiber_package/events/activity.py @@ -0,0 +1,25 @@ +from typing import Annotated, Self + +from .communication import CommunicationModel + +class ActivityModel(CommunicationModel): + category: Annotated[ + CommunicationCategory, + Field(pattern=CommunicationCategory.activity) + ] + + start_time: datetime + end_time: datetime + + + #signuplist: GroupRef | None = None + # TODO: implement signup list (huge modular system) + + # TODO: see Felt 'activiteiten' DB schema. Things like: + # costs, payment method, email, target group, maximal attendees .... + + @model_validator(mode='after') + def check_end_after_start(self) -> Self: + if self.end_time < self.start_time: + raise ValueError("End time cannot be earlier than start time") + return self diff --git a/src/fiber_package/events/communication.py b/src/fiber_package/events/communication.py new file mode 100644 index 0000000..257b632 --- /dev/null +++ b/src/fiber_package/events/communication.py @@ -0,0 +1,46 @@ +from pydantic import BaseModel, model_validator, Field, HttpUrl +from enum import StrEnum +from datetime import datetime + +from fiber_package.base import FiberBaseModel + +from .enums import CommunicationCategory + +''' +A "communication" is a piece of communication/promotion to be shared with +members, which may appear on the website and in the weekly mailing. +''' +class CommunicationModel(FiberBaseModel): + category: CommunicationCategory + + name_en: str + name_nl: str + + association_tags = [] + # list of associations this communication belongs to + + subtitle_en: str + subtitle_nl: str + # subtitles currently (2026) appear only in the table of contents in the + # weekly mailing; they are meant to be a short catchy flavour text + + description_en: str + description_nl: str + + image: HttpUrl | None = None + # often, a poster comes associated with a communication (in particular if + # it's an activity). In that case, the poster is uploaded to the cloud and + # the share link is attached to the communication + # TODO: potentially rethink the way images are attached to communications + + visibility: bool + # should this communication be shown to members at all? Useful for + # temporarily hiding a communication + + only_members: bool + # is this communication only visible to members? This refers to visibility + # on the website, i.e. is this only visible to visitors who are logged in? + + archived: bool + # an archived communication cannot be edited, only viewed for future + # reference \ No newline at end of file diff --git a/src/fiber_package/events/enums.py b/src/fiber_package/events/enums.py new file mode 100644 index 0000000..84682d2 --- /dev/null +++ b/src/fiber_package/events/enums.py @@ -0,0 +1,10 @@ +from enum import StrEnum + +''' +The category is only used to place the communication correctly in the weekly +mailing and the board-website, it is not visible (or relevant) to readers +''' +class CommunicationCategory(StrEnum): + announcement = "announcement" + news = "news" + activity = "activity"