-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/capr 23 scaffold event cog from deprecated repo #70
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
e459d8a
2a9d3cd
a906b04
a559294
543239a
d1aa416
03f6eef
e1c4e9d
4879b57
b5a9db5
2c43a58
74671bd
85e7528
09e2d38
b7bf291
a53b431
6a07b8f
0bbf85b
0488eb0
d2d2b6e
9860422
2e130fe
f4b2120
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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Event management module.""" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| 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, | ||
| ) | ||
|
Comment on lines
+10
to
+14
|
||
| 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(), | ||
| ) | ||
|
Comment on lines
+10
to
+19
|
||
| 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 | ||
|
Comment on lines
+10
to
+31
|
||
|
|
||
| @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: | ||
| parsed = datetime.strptime(f"{value} +0000", "%I:%M %p %z") | ||
| else: | ||
| parsed = datetime.strptime(f"{value} +0000", "%H:%M %z") | ||
| return parsed.timetz().replace(tzinfo=None) | ||
|
Comment on lines
+25
to
+42
|
||
| return value | ||
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.
A new setting is introduced but
example.envdoesn’t document it. Consider addingANNOUNCEMENT_CHANNEL_NAME=(or whatever env var name is expected by pydantic-settings) toexample.env/README so deployments know how to configure the announcement channel.