Allow the catch-all district to do uploads
This commit is contained in:
parent
2f61b224de
commit
434746aa99
3 changed files with 10 additions and 2 deletions
|
|
@ -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")),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue