From 59c6ce9da6d32aaf73db983446268f98c2e052bf Mon Sep 17 00:00:00 2001 From: Arnaud Delcasse Date: Fri, 10 Mar 2023 12:16:12 +0100 Subject: [PATCH] small updates --- handlers/application/agenda.go | 2 +- handlers/application/beneficiaries.go | 2 +- renderer/func-maps.go | 18 ++++++++++++++++++ renderer/renderer.go | 4 ++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/handlers/application/agenda.go b/handlers/application/agenda.go index f9395a4..69b1f40 100644 --- a/handlers/application/agenda.go +++ b/handlers/application/agenda.go @@ -231,7 +231,7 @@ func (h *ApplicationHandler) AgendaSubscribeEvent(w http.ResponseWriter, r *http "subscribed_by": map[string]any{ "user": map[string]any{ "id": current_user_token.Subject, - "display_name": current_user_claims["display_name"], + "display_name": fmt.Sprintf("%s %s", current_user_claims["first_name"], current_user_claims["last_name"]), }, "group": map[string]any{ "id": current_group.ID, diff --git a/handlers/application/beneficiaries.go b/handlers/application/beneficiaries.go index 460140c..f69b00a 100644 --- a/handlers/application/beneficiaries.go +++ b/handlers/application/beneficiaries.go @@ -269,7 +269,7 @@ func (h *ApplicationHandler) BeneficiaryDocuments(w http.ResponseWriter, r *http beneficiaryID := vars["beneficiaryid"] //r.ParseForm() - r.ParseMultipartForm(10 * 1024 * 1024) + r.ParseMultipartForm(100 * 1024 * 1024) document_type := r.FormValue("type") document_name := r.FormValue("name") diff --git a/renderer/func-maps.go b/renderer/func-maps.go index b18a0a5..3c5b005 100644 --- a/renderer/func-maps.go +++ b/renderer/func-maps.go @@ -1,9 +1,11 @@ package renderer import ( + "bytes" "encoding/json" "fmt" "html/template" + "strings" "time" "gitlab.scity.coop/maas/navitia-golang/types" @@ -67,6 +69,22 @@ func JSON(v any) template.JS { return template.JS(result) } +func RawJSON(v any) string { + buf := new(bytes.Buffer) + enc := json.NewEncoder(buf) + enc.SetEscapeHTML(false) + err := enc.Encode(&v) + if err != nil { + return "" + } + return strings.TrimSuffix(buf.String(), "\n") + +} + +func UnescapeHTML(s string) template.HTML { + return template.HTML(s) +} + func Dict(v ...interface{}) map[string]interface{} { dict := map[string]interface{}{} lenv := len(v) diff --git a/renderer/renderer.go b/renderer/renderer.go index 8b914d9..aae7262 100644 --- a/renderer/renderer.go +++ b/renderer/renderer.go @@ -55,6 +55,8 @@ func (renderer *Renderer) Render(name string, w http.ResponseWriter, r *http.Req "genderISO5218": GenderISO5218, "dict": Dict, "json": JSON, + "rawjson": RawJSON, + "unescapeHTML": UnescapeHTML, "walkingLength": WalkingLength, "divideFloat64": Divide[float64], "divideInt": Divide[int], @@ -83,6 +85,8 @@ func (renderer *Renderer) RenderNoLayout(name string, w http.ResponseWriter, r * "genderISO5218": GenderISO5218, "dict": Dict, "json": JSON, + "rawjson": RawJSON, + "unsescapeHTML": UnescapeHTML, "divideFloat64": Divide[float64], "divideInt": Divide[int], },