small updates

This commit is contained in:
Arnaud Delcasse 2023-03-10 12:16:12 +01:00
parent 439f819989
commit 59c6ce9da6
4 changed files with 24 additions and 2 deletions

View File

@ -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,

View File

@ -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")

View File

@ -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)

View File

@ -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],
},