-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/capr 23 scaffold event cog from deprecated repo #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8d11645
e048f59
c7f0e8f
739e2ca
fa7df28
4315fae
e356426
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -25,5 +25,8 @@ class Settings(EnvConfig): | |||||
| # Ticket System Configuration | ||||||
| ticket_feedback_channel_id: int = 0 | ||||||
|
|
||||||
| # Event System Configuration | ||||||
| announcement_channel_name: str = "test-announcements" | ||||||
|
||||||
| announcement_channel_name: str = "test-announcements" | |
| announcement_channel_name: str = "announcements" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Event management module.""" |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,46 @@ | ||||||||||||||
| from datetime import date, datetime, time | ||||||||||||||
|
|
||||||||||||||
| from pydantic import BaseModel, Field, field_validator | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| class EventSchema(BaseModel): | ||||||||||||||
| """Pydantic model defining the Event schema and validation rules.""" | ||||||||||||||
|
|
||||||||||||||
| event_name: str = Field(title="Event Name", description="Name of the event", max_length=100) | ||||||||||||||
| event_date: date = Field( | ||||||||||||||
| title="Event Date", | ||||||||||||||
| description="Date of the event (MM-DD-YYYY)", | ||||||||||||||
| default_factory=date.today, | ||||||||||||||
| ) | ||||||||||||||
| event_time: time = Field( | ||||||||||||||
| title="Event Time", | ||||||||||||||
| description="Time of the event (HH:MM, 24-hour) or (HH:MM AM/PM)", | ||||||||||||||
| default_factory=lambda: datetime.now().astimezone().time(), | ||||||||||||||
| ) | ||||||||||||||
| location: str = Field(title="Location", description="Location of the event", max_length=200, default="") | ||||||||||||||
| description: str = Field( | ||||||||||||||
| title="Description", description="Detailed description of the event", max_length=1000, default="" | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
| @field_validator("event_date", mode="before") | ||||||||||||||
| @classmethod | ||||||||||||||
| def _parse_event_date(cls, value: object) -> date | object: | ||||||||||||||
| if isinstance(value, str): | ||||||||||||||
| value = value.strip() | ||||||||||||||
| return datetime.strptime(f"{value} +0000", "%m-%d-%Y %z").date() | ||||||||||||||
| return value | ||||||||||||||
|
|
||||||||||||||
| @field_validator("event_time", mode="before") | ||||||||||||||
| @classmethod | ||||||||||||||
| def _parse_event_time(cls, value: object) -> time | object: | ||||||||||||||
| if isinstance(value, str): | ||||||||||||||
| value = value.strip() | ||||||||||||||
| if " " in value: | ||||||||||||||
| # Handle 00:XX AM/PM by converting to 12:XX AM/PM | ||||||||||||||
| if value.lower().startswith("00:"): | ||||||||||||||
|
||||||||||||||
| if value.lower().startswith("00:"): | |
| lower_value = value.lower() | |
| if lower_value.startswith("00:"): | |
| # 00:XX PM is not a valid 12-hour time; reject to avoid confusion | |
| if "pm" in lower_value: | |
| raise ValueError("Invalid time format: '00:XX PM' is not a valid 12-hour time.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new
announcement_channel_nameconfiguration setting is not documented in the example.env file. All other configuration settings in config.py have corresponding entries in example.env for documentation purposes. Users won't know this configuration option exists or how to override the default "test-announcements" value. Add an entry likeANNOUNCEMENT_CHANNEL_NAME=to example.env.