lint: remove unused code across api, comms, h3utils, html, middleware, minio, platform, rmo
Deleted files: api/compliance.go, api/debug.go, rmo/compliance.go, rmo/email.go, rmo/mock.go, platform/publicreport/address.go Removed unused functions/types from: api/api.go, api/configuration.go, api/district.go, api/publicreport.go, api/sudo.go, api/types.go, comms/text/twilio.go, comms/text/voipms.go, h3utils/h3.go, html/embed.go, html/form.go, middleware/terminal.go, minio/client.go, platform/csv/csv.go, platform/csv/flyover.go, platform/file/base.go, platform/file/upload.go, platform/geocode/address.go, platform/types/service_request.go
This commit is contained in:
parent
d74c24339e
commit
53a3f9816a
25 changed files with 6 additions and 975 deletions
|
|
@ -1,166 +0,0 @@
|
|||
package rmo
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/Gleipnir-Technology/nidus-sync/html"
|
||||
)
|
||||
|
||||
type ContentCompliance struct {
|
||||
District *ContentDistrict
|
||||
HasCompleteResponse bool
|
||||
HasUsefulInfo bool
|
||||
ReferenceNumber string
|
||||
URL ContentURL
|
||||
}
|
||||
|
||||
func getDistrictCompliance(w http.ResponseWriter, r *http.Request) {
|
||||
district, err := districtBySlug(r)
|
||||
if err != nil {
|
||||
respondError(w, "Failed to lookup organization", err, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
html.RenderOrError(
|
||||
w,
|
||||
"rmo/district-compliance.html",
|
||||
ContentCompliance{
|
||||
District: newContentDistrict(district),
|
||||
URL: makeContentURL(nil),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func getDistrictComplianceAddress(w http.ResponseWriter, r *http.Request) {
|
||||
district, err := districtBySlug(r)
|
||||
if err != nil {
|
||||
respondError(w, "Failed to lookup organization", err, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
html.RenderOrError(
|
||||
w,
|
||||
"rmo/district-compliance-address.html",
|
||||
ContentCompliance{
|
||||
District: newContentDistrict(district),
|
||||
URL: makeContentURL(nil),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func getDistrictComplianceComplete(w http.ResponseWriter, r *http.Request) {
|
||||
query := r.URL.Query()
|
||||
complete := query.Get("complete")
|
||||
is_complete := complete != ""
|
||||
useful := query.Get("useful")
|
||||
is_useful := useful != ""
|
||||
|
||||
district, err := districtBySlug(r)
|
||||
if err != nil {
|
||||
respondError(w, "Failed to lookup organization", err, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
html.RenderOrError(
|
||||
w,
|
||||
"rmo/district-compliance-complete.html",
|
||||
ContentCompliance{
|
||||
District: newContentDistrict(district),
|
||||
HasCompleteResponse: is_complete,
|
||||
HasUsefulInfo: is_useful,
|
||||
ReferenceNumber: "ABC-123",
|
||||
URL: makeContentURL(nil),
|
||||
},
|
||||
)
|
||||
}
|
||||
func getDistrictComplianceConcern(w http.ResponseWriter, r *http.Request) {
|
||||
district, err := districtBySlug(r)
|
||||
if err != nil {
|
||||
respondError(w, "Failed to lookup organization", err, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
html.RenderOrError(
|
||||
w,
|
||||
"rmo/district-compliance-concern.html",
|
||||
ContentCompliance{
|
||||
District: newContentDistrict(district),
|
||||
URL: makeContentURL(nil),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func getDistrictComplianceContact(w http.ResponseWriter, r *http.Request) {
|
||||
district, err := districtBySlug(r)
|
||||
if err != nil {
|
||||
respondError(w, "Failed to lookup organization", err, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
html.RenderOrError(
|
||||
w,
|
||||
"rmo/district-compliance-contact.html",
|
||||
ContentCompliance{
|
||||
District: newContentDistrict(district),
|
||||
URL: makeContentURL(nil),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func getDistrictComplianceEvidence(w http.ResponseWriter, r *http.Request) {
|
||||
district, err := districtBySlug(r)
|
||||
if err != nil {
|
||||
respondError(w, "Failed to lookup organization", err, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
html.RenderOrError(
|
||||
w,
|
||||
"rmo/district-compliance-evidence.html",
|
||||
ContentCompliance{
|
||||
District: newContentDistrict(district),
|
||||
URL: makeContentURL(nil),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func getDistrictCompliancePermission(w http.ResponseWriter, r *http.Request) {
|
||||
district, err := districtBySlug(r)
|
||||
if err != nil {
|
||||
respondError(w, "Failed to lookup organization", err, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
html.RenderOrError(
|
||||
w,
|
||||
"rmo/district-compliance-permission.html",
|
||||
ContentCompliance{
|
||||
District: newContentDistrict(district),
|
||||
URL: makeContentURL(nil),
|
||||
},
|
||||
)
|
||||
}
|
||||
func getDistrictComplianceProcess(w http.ResponseWriter, r *http.Request) {
|
||||
district, err := districtBySlug(r)
|
||||
if err != nil {
|
||||
respondError(w, "Failed to lookup organization", err, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
html.RenderOrError(
|
||||
w,
|
||||
"rmo/district-compliance-process.html",
|
||||
ContentCompliance{
|
||||
District: newContentDistrict(district),
|
||||
URL: makeContentURL(nil),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func getDistrictComplianceSubmit(w http.ResponseWriter, r *http.Request) {
|
||||
district, err := districtBySlug(r)
|
||||
if err != nil {
|
||||
respondError(w, "Failed to lookup organization", err, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
html.RenderOrError(
|
||||
w,
|
||||
"rmo/district-compliance-submit.html",
|
||||
ContentCompliance{
|
||||
District: newContentDistrict(district),
|
||||
URL: makeContentURL(nil),
|
||||
},
|
||||
)
|
||||
}
|
||||
124
rmo/email.go
124
rmo/email.go
|
|
@ -1,124 +0,0 @@
|
|||
package rmo
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/lint"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/html"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/platform/email"
|
||||
"github.com/aarondl/opt/omit"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
type ContentEmail struct {
|
||||
Email string
|
||||
}
|
||||
|
||||
func getEmailByCode(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
id := vars["code"]
|
||||
//id := r.FormValue("id")
|
||||
if id == "" {
|
||||
http.Error(w, "You must specify an id", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
ctx := r.Context()
|
||||
email_log, err := models.CommsEmailLogs.Query(
|
||||
models.SelectWhere.CommsEmailLogs.PublicID.EQ(id),
|
||||
).One(ctx, db.PGInstance.BobDB)
|
||||
if err != nil {
|
||||
respondError(w, "Failed to query email_log: %w", err, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
html, err := email.RenderHTML(email_log.TemplateID, email_log.TemplateData)
|
||||
if err != nil {
|
||||
respondError(w, "Failed to render email_log: %w", err, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
lint.Write(w, html)
|
||||
}
|
||||
func getEmailReportUnsubscribe(w http.ResponseWriter, r *http.Request) {
|
||||
email := r.FormValue("email")
|
||||
html.RenderOrError(
|
||||
w,
|
||||
"rmo/email-unsubscribe.html",
|
||||
ContentEmail{
|
||||
Email: email,
|
||||
},
|
||||
)
|
||||
}
|
||||
func getEmailConfirm(w http.ResponseWriter, r *http.Request) {
|
||||
email := r.FormValue("email")
|
||||
if email == "" {
|
||||
respondError(w, "Not sure what to do with an empty email", nil, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
html.RenderOrError(
|
||||
w,
|
||||
"rmo/email-confirm.html",
|
||||
ContentEmail{
|
||||
Email: email,
|
||||
},
|
||||
)
|
||||
}
|
||||
func getEmailConfirmComplete(w http.ResponseWriter, r *http.Request) {
|
||||
html.RenderOrError(
|
||||
w,
|
||||
"rmo/email-confirm-complete.html",
|
||||
map[string]string{},
|
||||
)
|
||||
}
|
||||
func getEmailUnsubscribe(w http.ResponseWriter, r *http.Request) {
|
||||
email := r.FormValue("email")
|
||||
html.RenderOrError(
|
||||
w,
|
||||
"rmo/email-unsubscribe.html",
|
||||
ContentEmail{
|
||||
Email: email,
|
||||
},
|
||||
)
|
||||
}
|
||||
func getEmailUnsubscribeComplete(w http.ResponseWriter, r *http.Request) {
|
||||
html.RenderOrError(
|
||||
w,
|
||||
"rmo/email-unsubscribe-complete.html",
|
||||
map[string]string{},
|
||||
)
|
||||
}
|
||||
func postEmailConfirm(w http.ResponseWriter, r *http.Request) {
|
||||
email := r.PostFormValue("email")
|
||||
if email == "" {
|
||||
respondError(w, "Not sure what to do with an empty email", nil, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
ctx := r.Context()
|
||||
email_contact, err := models.FindCommsEmailContact(ctx, db.PGInstance.BobDB, email)
|
||||
if err != nil {
|
||||
respondError(w, "Email not in the database", err, http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
err = email_contact.Update(ctx, db.PGInstance.BobDB, &models.CommsEmailContactSetter{
|
||||
Confirmed: omit.From(true),
|
||||
})
|
||||
http.Redirect(w, r, "/email/confirm/complete", http.StatusFound)
|
||||
}
|
||||
func postEmailUnsubscribe(w http.ResponseWriter, r *http.Request) {
|
||||
email := r.PostFormValue("email")
|
||||
if email == "" {
|
||||
respondError(w, "Not sure what to do with an empty email", nil, http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
ctx := r.Context()
|
||||
email_contact, err := models.FindCommsEmailContact(ctx, db.PGInstance.BobDB, email)
|
||||
if err != nil {
|
||||
respondError(w, "Email not in the database", err, http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
err = email_contact.Update(ctx, db.PGInstance.BobDB, &models.CommsEmailContactSetter{
|
||||
IsSubscribed: omit.From(false),
|
||||
})
|
||||
http.Redirect(w, r, "/email/unsubscribe/complete", http.StatusFound)
|
||||
}
|
||||
57
rmo/mock.go
57
rmo/mock.go
|
|
@ -1,57 +0,0 @@
|
|||
package rmo
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/Gleipnir-Technology/nidus-sync/config"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/html"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
type ContentMock struct {
|
||||
District ContentDistrict
|
||||
ReportID string
|
||||
URL ContentURL
|
||||
}
|
||||
|
||||
func addMockRoutes(r *mux.Router) {
|
||||
r.HandleFunc("/", renderMock("rmo/mock/root.html"))
|
||||
r.HandleFunc("/district/{slug}", renderMock("rmo/mock/district-root.html"))
|
||||
r.HandleFunc("/district/{slug}/nuisance-submit-complete", renderMock("rmo/mock/nuisance-submit-complete.html"))
|
||||
r.HandleFunc("/nuisance", renderMock("rmo/mock/nuisance.html"))
|
||||
r.HandleFunc("/nuisance-submit-complete", renderMock("rmo/mock/nuisance-submit-complete.html"))
|
||||
}
|
||||
|
||||
func makeContentURLMock(slug string) ContentURL {
|
||||
return ContentURL{
|
||||
Nuisance: makeURLMock(slug, "nuisance"),
|
||||
SubmitComplete: makeURLMock(slug, "nuisance-submit-complete"),
|
||||
Tegola: config.MakeURLTegola("/"),
|
||||
Water: makeURLMock(slug, "water"),
|
||||
}
|
||||
}
|
||||
func makeURLMock(slug, p string) string {
|
||||
return config.MakeURLReport("/mock/district/%s/%s", slug, p)
|
||||
}
|
||||
func renderMock(t string) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
slug := vars["slug"]
|
||||
if slug == "" {
|
||||
slug = "delta-mvcd"
|
||||
}
|
||||
html.RenderOrError(
|
||||
w,
|
||||
t,
|
||||
ContentMock{
|
||||
District: ContentDistrict{
|
||||
Name: "Delta MVCD",
|
||||
URLLogo: config.MakeURLNidus("/api/district/%s/logo", slug),
|
||||
URLWebsite: "http://www.deltavcd.com/",
|
||||
},
|
||||
ReportID: "abcd-1234-5678",
|
||||
URL: makeContentURLMock(slug),
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue