-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
65 lines (57 loc) · 1.8 KB
/
models.py
File metadata and controls
65 lines (57 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""
Data models for the event scraper application.
"""
from dataclasses import dataclass
from datetime import datetime
from typing import Optional
@dataclass
class Event:
"""Represents a single event."""
id: Optional[int] = None
name: str = ""
date_time: Optional[datetime] = None
location: str = ""
description: str = ""
source_url: str = ""
source_name: str = ""
category: str = "general"
cost: str = "" # Free, $10, $5-15, etc.
organizer: str = "" # Who's organizing the event
contact_info: str = "" # Phone, email, website
registration_required: bool = False
age_restrictions: str = "" # All ages, 21+, Kids only, etc.
created_at: Optional[datetime] = None
def __post_init__(self):
if self.created_at is None:
self.created_at = datetime.now()
def to_dict(self):
"""Convert event to dictionary for JSON serialization."""
return {
'id': self.id,
'name': self.name,
'date_time': self.date_time.isoformat() if self.date_time else None,
'location': self.location,
'description': self.description,
'source_url': self.source_url,
'source_name': self.source_name,
'category': self.category,
'cost': self.cost,
'organizer': self.organizer,
'contact_info': self.contact_info,
'registration_required': self.registration_required,
'age_restrictions': self.age_restrictions,
'created_at': self.created_at.isoformat() if self.created_at else None
}
# Event categories for filtering
EVENT_CATEGORIES = [
'general',
'family',
'music',
'outdoors',
'sports',
'arts',
'food',
'business',
'education',
'community'
]