From cefb7ffa07f6d3e555dd06a9efb34bc99762c9d5 Mon Sep 17 00:00:00 2001 From: RandomChars <random@chars.jp> Date: Wed, 15 Dec 2021 23:39:30 +0900 Subject: [PATCH] insert placeholders --- assets/templates/form.tmpl | 20 +++++++++----------- routes.go | 33 +++++++++++++++++---------------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/assets/templates/form.tmpl b/assets/templates/form.tmpl index 3891641..04ee3d9 100644 --- a/assets/templates/form.tmpl +++ b/assets/templates/form.tmpl @@ -9,20 +9,19 @@ <div class="col-lg-6 col-xs-12 form-area"> <div class="form-container"> <div class="section-title title-style-three mb-20"> - {{range .}} - <h2>{{.Name}} <span>FORMU</span></h2> + <h2>{{.tournament.Title}} <span>FORMU</span></h2> </div> <div class="contact-form"> <form action="#"> <div class="row"> - {{if .Team}} - <div class="col-md-12"> - <input name="teamName" type="text" placeholder="Takım Adınız"> - </div> - <div class="col-md-6"> - <input type="text" placeholder="Takım Kaptanınız"> - </div> - {{end}} + {{/* {{if .Team}}*/}} + {{/* <div class="col-md-12">*/}} + {{/* <input name="teamName" type="text" placeholder="Takım Adınız">*/}} + {{/* </div>*/}} + {{/* <div class="col-md-6">*/}} + {{/* <input type="text" placeholder="Takım Kaptanınız">*/}} + {{/* </div>*/}} + {{/* {{end}}*/}} <div class="col-md-6"> <input type="text" placeholder="Adınız"> </div> @@ -38,7 +37,6 @@ {{/* {{ end }}*/}} </div> - {{end}} <button>Gönder</button> </form> </div> diff --git a/routes.go b/routes.go index ce97232..47109d0 100644 --- a/routes.go +++ b/routes.go @@ -36,26 +36,26 @@ func registerRoutes() { // TODO: consume user stuff here - var t *tournament - if id, err := uuid.Parse(context.Param("id")); err != nil { - if config.System.Verbose { - log.Printf("error parsing UUID %s: %s", context.Param("id"), err) - } - context.Redirect(http.StatusTemporaryRedirect, "/") + t := contextTournament(context) + if t == nil { return - } else { - if t, _, err = getTournament(id); err != nil { - if config.System.Verbose { - log.Printf("error fetching form %s: %s", id.String(), err) - } - context.Redirect(http.StatusTemporaryRedirect, "/") - return - } } - populateTournament(t) + + authText, authRef := getAuthButton(user) + + sy, sm, sd := t.StartTime.Date() + dy, dm, dd := t.Deadline.Date() context.HTML(http.StatusOK, "form.tmpl", gin.H{ - "tournament": t, + "auth_text": authText, + "auth_ref": authRef, + "tournament": tournamentPayload{ + Title: t.Attributes["title"], + StartTimeString: fmt.Sprintf("%d-%.2d-%.2d", sy, sm, sd), + DeadlineString: fmt.Sprintf("%d-%.2d-%.2d", dy, dm, dd), + TeamSizeString: t.Attributes["size"], + Prize: t.Attributes["prize"], + }, }) }) @@ -67,6 +67,7 @@ func registerRoutes() { } // TODO: handle form submit + context.String(http.StatusOK, "TODO") }) router.GET("/admin", func(context *gin.Context) { -- GitLab