feature: Added Transactions and major Order System Overhaul
This commit is contained in:
@@ -119,7 +119,7 @@ class DeviceCreate(BaseModel):
|
||||
device_subscription: DeviceSubInformation = DeviceSubInformation()
|
||||
device_stats: DeviceStatistics = DeviceStatistics()
|
||||
events_on: bool = False
|
||||
device_location_coordinates: str = ""
|
||||
device_location_coordinates: Any = None # GeoPoint dict {lat, lng} or legacy str
|
||||
device_melodies_all: List[MelodyMainItem] = []
|
||||
device_melodies_favorites: List[str] = []
|
||||
user_list: List[str] = []
|
||||
@@ -144,7 +144,7 @@ class DeviceUpdate(BaseModel):
|
||||
device_subscription: Optional[Dict[str, Any]] = None
|
||||
device_stats: Optional[Dict[str, Any]] = None
|
||||
events_on: Optional[bool] = None
|
||||
device_location_coordinates: Optional[str] = None
|
||||
device_location_coordinates: Optional[Any] = None # dict {lat, lng} or legacy str
|
||||
device_melodies_all: Optional[List[MelodyMainItem]] = None
|
||||
device_melodies_favorites: Optional[List[str]] = None
|
||||
user_list: Optional[List[str]] = None
|
||||
|
||||
@@ -72,7 +72,7 @@ def _convert_firestore_value(val):
|
||||
# Firestore DatetimeWithNanoseconds is a datetime subclass
|
||||
return val.strftime("%d %B %Y at %H:%M:%S UTC%z")
|
||||
if isinstance(val, GeoPoint):
|
||||
return f"{val.latitude}° N, {val.longitude}° E"
|
||||
return {"lat": val.latitude, "lng": val.longitude}
|
||||
if isinstance(val, DocumentReference):
|
||||
# Store the document path (e.g. "users/abc123")
|
||||
return val.path
|
||||
@@ -213,6 +213,11 @@ def update_device(device_doc_id: str, data: DeviceUpdate) -> DeviceInDB:
|
||||
|
||||
update_data = data.model_dump(exclude_none=True)
|
||||
|
||||
# Convert {lat, lng} dict to a Firestore GeoPoint
|
||||
coords = update_data.get("device_location_coordinates")
|
||||
if isinstance(coords, dict) and "lat" in coords and "lng" in coords:
|
||||
update_data["device_location_coordinates"] = GeoPoint(coords["lat"], coords["lng"])
|
||||
|
||||
# Deep-merge nested structs so unmentioned sub-fields are preserved
|
||||
existing = doc.to_dict()
|
||||
nested_keys = (
|
||||
|
||||
Reference in New Issue
Block a user