From 2f61b224deac866b341a22a98f7938521972b424 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Thu, 19 Mar 2026 03:19:58 +0000 Subject: [PATCH] Prevent creating CSV uploads without a service area --- platform/organization.go | 3 +++ sync/upload.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/platform/organization.go b/platform/organization.go index 27921868..50f5a02b 100644 --- a/platform/organization.go +++ b/platform/organization.go @@ -46,6 +46,9 @@ func (o Organization) CountTrap(ctx context.Context) (uint, error) { } return uint(result), nil } +func (o Organization) HasServiceArea() bool { + return o.model.ServiceAreaGeometry.IsValue() +} func (o Organization) Name() string { return o.model.Name } diff --git a/sync/upload.go b/sync/upload.go index 19004dd7..97ccf66b 100644 --- a/sync/upload.go +++ b/sync/upload.go @@ -107,6 +107,10 @@ func postUploadDiscard(ctx context.Context, r *http.Request, u platform.User, f 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() { + return "", nhttp.NewErrorStatus(http.StatusConflict, "Your organization does not yet have a service area") + } uploads, err := file.SaveFileUpload(r, "csvfile", file.CollectionCSV) if err != nil { return "", nhttp.NewError("Failed to extract image uploads: %s", err)