Make urls with district slugs
This commit is contained in:
parent
c435feeebc
commit
93079c5c8e
2 changed files with 25 additions and 14 deletions
|
|
@ -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),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
35
rmo/root.go
35
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue