Add site contact information

This commit is contained in:
Eli Ribble 2026-04-16 07:12:34 +00:00
parent 671397ba81
commit b9c257a635
No known key found for this signature in database

View file

@ -14,15 +14,21 @@ type Site struct {
ID int32 `db:"id" json:"id"`
Notes string `db:"notes" json:"notes"`
OrganizationID int32 `db:"organization_id" json:"organization_id"`
Owner *Contact `db:"owner" json:"owner"`
Owner Contact `db:"owner" json:"owner"`
ParcelID *int32 `db:"parcel_id" json:"parcel_id"`
Resident *Contact `db:"resident" json:"resident"`
ResidentOwned bool `db:"resident_owned" json:"resident_owned"`
ResidentOwned *bool `db:"resident_owned" json:"resident_owned"`
Tags map[string]string `db:"tags" json:"tags"`
Version int32 `db:"version" json:"version"`
}
func SiteFromModel(s *models.Site) Site {
owner_phone := s.OwnerPhoneE164.GetOr("")
var resident_owned *bool
if s.ResidentOwned.IsValue() {
b := s.ResidentOwned.MustGet()
resident_owned = &b
}
return Site{
Created: s.Created,
CreatorID: s.CreatorID,
@ -30,6 +36,11 @@ func SiteFromModel(s *models.Site) Site {
ID: s.ID,
Notes: s.Notes,
OrganizationID: s.OrganizationID,
Owner: Contact{
Name: &s.OwnerName,
Phone: &owner_phone,
},
ResidentOwned: resident_owned,
//ParcelID: s.ParcelID,
}
}