mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-06 06:30:51 -04:00
Introduce "areas_2" so we can repurpose "areas"
Currently we have: - An "areas" column in the DB that stores a JSON blob. - An "areas" field inside the "areas" JSON that stores area IDs. - Each field has to be manually copied into the JSON column. We want to move to: - An "areas" column in the DB (unchanged). - An "ids" field inside the "areas" JSON (to replace "areas"). - The Admin app sending other data inside an "areas" JSON field. The API design for areas is confusing and difficult to extend. Here we duplicate the current API functionality using an "areas_2" field. Once the Admin app is using this field, we'll be able to rename it to just "areas", which is where we want to get to. In the next commits we'll build on this to support the migration from "areas"."areas" to "areas"."ids".
This commit is contained in:
@@ -2336,6 +2336,11 @@ class BroadcastMessage(db.Model):
|
||||
self._personalisation = encryption.encrypt(personalisation or {})
|
||||
|
||||
def serialize(self):
|
||||
# TEMPORARY: while we repurpose "areas"
|
||||
areas_2 = dict(self.areas)
|
||||
areas_2["simple_polygons"] = areas_2.get("simple_polygons", [])
|
||||
areas_2["areas"] = areas_2.get("areas", [])
|
||||
|
||||
return {
|
||||
'id': str(self.id),
|
||||
'reference': self.reference,
|
||||
@@ -2348,6 +2353,8 @@ class BroadcastMessage(db.Model):
|
||||
'personalisation': self.personalisation if self.template else None,
|
||||
'content': self.content,
|
||||
|
||||
# TEMPORARY: switch to this so we can repurpose "areas"
|
||||
'areas_2': areas_2,
|
||||
'areas': self.areas.get("areas", []),
|
||||
'simple_polygons': self.areas.get("simple_polygons", []),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user