Allow the catch-all district to do uploads

This commit is contained in:
Eli Ribble 2026-03-19 03:25:36 +00:00
parent 2f61b224de
commit 434746aa99
No known key found for this signature in database
3 changed files with 10 additions and 2 deletions

View file

@ -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")),

View file

@ -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
}

View file

@ -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)