diff --git a/platform/csv/flyover.go b/platform/csv/flyover.go index 5290aeec..0613b637 100644 --- a/platform/csv/flyover.go +++ b/platform/csv/flyover.go @@ -223,7 +223,12 @@ func insertFlyover(ctx context.Context, txn bob.Tx, file *models.FileuploadFile, um.TableAs("fileupload.pool", "pool"), um.SetCol("h3cell").ToArg(cell), um.SetCol("geom").To(geom_query), - um.SetCol("is_in_district").To(psql.F("ST_Contains", "org.service_area_geometry", geom_query)), + um.SetCol("is_in_district").To( + psql.F("COALESCE", + psql.F("ST_Contains", "org.service_area_geometry", geom_query), + psql.Quote("org", "is_catchall"), + ), + ), um.From("fileupload.csv").As("csv"), um.InnerJoin("fileupload.file").As("file").OnEQ(psql.Quote("csv", "file_id"), psql.Quote("file", "id")), um.InnerJoin("organization").As("org").OnEQ(psql.Quote("file", "organization_id"), psql.Quote("org", "id")), diff --git a/platform/organization.go b/platform/organization.go index 50f5a02b..14e91283 100644 --- a/platform/organization.go +++ b/platform/organization.go @@ -49,6 +49,9 @@ func (o Organization) CountTrap(ctx context.Context) (uint, error) { func (o Organization) HasServiceArea() bool { return o.model.ServiceAreaGeometry.IsValue() } +func (o Organization) IsCatchall() bool { + return o.model.IsCatchall +} func (o Organization) Name() string { return o.model.Name } diff --git a/sync/upload.go b/sync/upload.go index 97ccf66b..597dda48 100644 --- a/sync/upload.go +++ b/sync/upload.go @@ -108,7 +108,7 @@ type FormUploadPool struct{} func postUploadPoolFlyoverCreate(ctx context.Context, r *http.Request, u platform.User, f FormUploadPool) (string, *nhttp.ErrorWithStatus) { // If the organization we're uploading to doesn't have a service area, we can't process the upload correctly - if !u.Organization.HasServiceArea() { + if !(u.Organization.HasServiceArea() || u.Organization.IsCatchall()) { return "", nhttp.NewErrorStatus(http.StatusConflict, "Your organization does not yet have a service area") } uploads, err := file.SaveFileUpload(r, "csvfile", file.CollectionCSV)