-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_models.py
More file actions
75 lines (68 loc) · 2 KB
/
data_models.py
File metadata and controls
75 lines (68 loc) · 2 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
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
"""
Data Models for Attendance System
Contains dataclasses for AttendanceRecord and MembershipRecord.
"""
from dataclasses import dataclass
from datetime import datetime
from typing import List
@dataclass
class AttendanceRecord:
"""Represents an attendance record."""
timestamp: datetime
eid: str
type: str
activity: str
subactivity: str
@classmethod
def from_row(cls, row: List[str]) -> 'AttendanceRecord':
"""Create an AttendanceRecord from a spreadsheet row."""
return cls(
timestamp=datetime.fromisoformat(row[0].replace('Z', '+00:00')),
eid=row[1],
type=row[2],
activity=row[3],
subactivity=row[4] if len(row) > 4 else ""
)
@dataclass
class MembershipRecord:
"""Represents a membership record."""
timestamp: datetime
eid: str
type: str
firstname: str
lastname: str
email: str
committees: str
referral: str
major: str
joined_discord: str
agree_to_waiver: str
grad_semester: str
gender: str
hispanic: str
race: str
minor: str
@classmethod
def from_row(cls, row: List[str]) -> 'MembershipRecord':
"""Create a MembershipRecord from a spreadsheet row."""
# Pad row with empty strings if needed
padded_row = row + [''] * (16 - len(row))
return cls(
timestamp=datetime.fromisoformat(padded_row[0].replace('Z', '+00:00')),
eid=padded_row[1],
type=padded_row[2],
firstname=padded_row[3],
lastname=padded_row[4],
email=padded_row[5],
committees=padded_row[6],
referral=padded_row[7],
major=padded_row[8],
joined_discord=padded_row[9],
agree_to_waiver=padded_row[10],
grad_semester=padded_row[11],
gender=padded_row[12],
hispanic=padded_row[13],
race=padded_row[14],
minor=padded_row[15]
)