From 93079c5c8ef8e72b7056431a9ac9b57a79dc4ab3 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Sun, 1 Feb 2026 03:07:46 +0000 Subject: [PATCH] Make urls with district slugs --- rmo/nuisance.go | 4 ++-- rmo/root.go | 35 +++++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/rmo/nuisance.go b/rmo/nuisance.go index 30bdefd8..5a3003f7 100644 --- a/rmo/nuisance.go +++ b/rmo/nuisance.go @@ -44,7 +44,7 @@ func getNuisance(w http.ResponseWriter, r *http.Request) { ContentNuisance{ District: nil, MapboxToken: config.MapboxToken, - URL: makeContentURL(), + URL: makeContentURL(nil), }, ) } @@ -61,7 +61,7 @@ func getSubmitComplete(w http.ResponseWriter, r *http.Request) { ContentNuisanceSubmitComplete{ District: newContentDistrict(district), ReportID: report_id, - URL: makeContentURL(), + URL: makeContentURL(nil), }, ) } diff --git a/rmo/root.go b/rmo/root.go index f8b5a9f5..46fc1c94 100644 --- a/rmo/root.go +++ b/rmo/root.go @@ -62,7 +62,7 @@ func getRoot(w http.ResponseWriter, r *http.Request) { w, RootT, ContentRoot{ - URL: makeContentURL(), + URL: makeContentURL(nil), }, ) } @@ -80,7 +80,7 @@ func getRootDistrict(w http.ResponseWriter, r *http.Request) { RootT, ContentRoot{ District: newContentDistrict(district), - URL: makeContentURL(), + URL: makeContentURL(district), }, ) } @@ -94,23 +94,34 @@ func getTerms(w http.ResponseWriter, r *http.Request) { w, TermsT, ContentRoot{ - URL: makeContentURL(), + URL: makeContentURL(nil), }, ) } -func makeContentURL() ContentURL { - return ContentURL{ - Nuisance: makeURL("nuisance"), - NuisanceSubmit: makeURL("nuisance"), - Status: makeURL("status"), - Tegola: config.MakeURLTegola("/"), - Water: makeURL("water"), +func makeContentURL(district *models.Organization) ContentURL { + if district == nil || district.Slug.IsNull() { + return ContentURL{ + Nuisance: makeURL("/nuisance"), + NuisanceSubmit: makeURL("/nuisance"), + Status: makeURL("/status"), + Tegola: config.MakeURLTegola("/"), + Water: makeURL("/water"), + } + } else { + slug := district.Slug.MustGet() + return ContentURL{ + Nuisance: makeURL("/district/%s/nuisance", slug), + NuisanceSubmit: makeURL("/district/%s/nuisance", slug), + Status: makeURL("/status"), + Tegola: config.MakeURLTegola("/"), + Water: makeURL("/district/%s/water", slug), + } } } -func makeURL(p string) string { - return config.MakeURLReport("/%s", p) +func makeURL(f string, args ...string) string { + return config.MakeURLReport(f, args...) } // Respond with an error that is visible to the user