-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_settings.py
More file actions
99 lines (65 loc) · 2.86 KB
/
Copy pathuser_settings.py
File metadata and controls
99 lines (65 loc) · 2.86 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
from datetime import datetime, timezone
from typing import Any
from pydantic import BaseModel, ConfigDict, Field
from app.domain.enums import EventType, NotificationChannel, Theme
class NotificationSettings(BaseModel):
"""User notification preferences"""
model_config = ConfigDict(from_attributes=True, json_schema_serialization_defaults_required=True)
execution_completed: bool = True
execution_failed: bool = True
system_updates: bool = True
security_alerts: bool = True
channels: list[NotificationChannel] = [NotificationChannel.IN_APP]
class EditorSettings(BaseModel):
"""Code editor preferences"""
model_config = ConfigDict(from_attributes=True, json_schema_serialization_defaults_required=True)
font_size: int = 14
tab_size: int = 4
use_tabs: bool = False
word_wrap: bool = True
show_line_numbers: bool = True
class UserSettings(BaseModel):
"""Complete user settings model"""
model_config = ConfigDict(from_attributes=True, json_schema_serialization_defaults_required=True)
user_id: str
theme: Theme = Theme.AUTO
timezone: str = "UTC"
date_format: str = "YYYY-MM-DD"
time_format: str = "24h"
notifications: NotificationSettings = Field(default_factory=NotificationSettings)
editor: EditorSettings = Field(default_factory=EditorSettings)
custom_settings: dict[str, Any] = Field(default_factory=dict)
version: int = 1
created_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
updated_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
class UserSettingsUpdate(BaseModel):
"""Partial update model for user settings"""
model_config = ConfigDict(from_attributes=True, json_schema_serialization_defaults_required=True)
theme: Theme | None = None
timezone: str | None = None
date_format: str | None = None
time_format: str | None = None
notifications: NotificationSettings | None = None
editor: EditorSettings | None = None
custom_settings: dict[str, Any] | None = None
class ThemeUpdateRequest(BaseModel):
"""Request model for theme update"""
theme: Theme
class SettingsHistoryEntry(BaseModel):
"""Single entry in settings history"""
model_config = ConfigDict(from_attributes=True, json_schema_serialization_defaults_required=True)
timestamp: datetime
event_type: EventType
field: str
old_value: Any
new_value: Any
reason: str | None = None
class SettingsHistoryResponse(BaseModel):
"""Response model for settings history (limited snapshot of recent changes)"""
model_config = ConfigDict(from_attributes=True, json_schema_serialization_defaults_required=True)
history: list[SettingsHistoryEntry]
limit: int
class RestoreSettingsRequest(BaseModel):
"""Request model for restoring settings"""
timestamp: datetime
reason: str | None = None