From 8f3a5b35c85215a917b7d2883bdd6232fe432d8d Mon Sep 17 00:00:00 2001 From: Brian Wiborg Date: Mon, 13 May 2024 13:20:26 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20Better=20titles;=20go=20fmt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- http/main.go | 10 +++++++--- store/handler.go | 2 +- voting/main.go | 2 +- voting/vote/vote.go | 6 +++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/http/main.go b/http/main.go index 1ef2903..6d349a5 100644 --- a/http/main.go +++ b/http/main.go @@ -94,7 +94,9 @@ func handleNewVoting(ctx echo.Context) error { } func handleVotingForm(ctx echo.Context) error { - return ctx.Render(http.StatusOK, "voting_form", nil) + return ctx.Render(http.StatusOK, "voting_form", map[string]interface{}{ + "Title": "cvote", + }) } func handleVote(ctx echo.Context) error { @@ -122,8 +124,9 @@ func handleVote(ctx echo.Context) error { } store.PlaceVote(id, vid, elector, c) return ctx.Render(http.StatusFound, "thanks", map[string]interface{}{ - "Id": id, - "Vid": vid, + "Title": "cvote | thx", + "Id": id, + "Vid": vid, }) } @@ -138,6 +141,7 @@ func handleShowVoting(ctx echo.Context) error { } } return ctx.Render(http.StatusOK, "voting", map[string]interface{}{ + "Title": "cvote | " + v.Referendum(), "Voting": v, }) } diff --git a/store/handler.go b/store/handler.go index 61cb3c2..73fbf6d 100644 --- a/store/handler.go +++ b/store/handler.go @@ -86,7 +86,7 @@ func getVotes(id string) ([]vote.Vote, error) { return nil, err } var ( - i string + i string e string c vote.Choice ts time.Time diff --git a/voting/main.go b/voting/main.go index e45fa89..7f5bccc 100644 --- a/voting/main.go +++ b/voting/main.go @@ -129,7 +129,7 @@ func (v Voting) Electors() []string { } func (v Voting) Anonymous() bool { - return v.annonymous + return v.annonymous } func (v Voting) IsOpen() bool { diff --git a/voting/vote/vote.go b/voting/vote/vote.go index 2ca4d74..94c18b2 100644 --- a/voting/vote/vote.go +++ b/voting/vote/vote.go @@ -6,7 +6,7 @@ import ( ) type Vote struct { - Id string + Id string Elector string Choice Choice timestamp time.Time @@ -14,7 +14,7 @@ type Vote struct { func NewVote(id, elector string, choice Choice) Vote { return Vote{ - Id: id, + Id: id, Elector: elector, Choice: choice, timestamp: time.Now().UTC(), @@ -23,7 +23,7 @@ func NewVote(id, elector string, choice Choice) Vote { func NewVoteWithTimestamp(id, elector string, choice Choice, timestamp time.Time) Vote { return Vote{ - Id: id, + Id: id, Elector: elector, Choice: choice, timestamp: timestamp,