diff --git a/README.md b/README.md index e3ae5f0..306981a 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ VOTE_SLACK_BOT_TOKEN= ### Dev Overrides `DEV_DISABLE_ACTIVE_FILTERS="true"` will disable the requirements that you be active to vote +`DEV_FORCE_IS_EBOARD="true"` will force vote to treat all users as E-Board members `DEV_FORCE_IS_EVALS="true"` will force vote to treat all users as the Evals director ## Linting @@ -56,7 +57,7 @@ go vet *.go - [ ] Don't let the user fuck it up - [ ] Show E-Board polls with a higher priority - [x] Move Hide Vote to create instead of after you vote :skull: -- [ ] Display the reason why a user is on the results page of a running poll +- [X] Display the reason why a user is on the results page of a running poll - [ ] Display minimum time left that a poll is open - [ ] Move routes to their own functions -- [ ] Change HTTP resposne codes to be `http.something` instead of just a number +- [X] Change HTTP resposne codes to be `http.something` instead of just a number diff --git a/main.go b/main.go index 2ebf676..de44a2a 100644 --- a/main.go +++ b/main.go @@ -31,6 +31,7 @@ var VOTE_HOST = os.Getenv("VOTE_HOST") // Dev mode flags var DEV_DISABLE_ACTIVE_FILTERS bool = os.Getenv("DEV_DISABLE_ACTIVE_FILTERS") == "true" +var DEV_FORCE_IS_EBOARD bool = os.Getenv("DEV_FORCE_IS_EBOARD") == "true" var DEV_FORCE_IS_EVALS bool = os.Getenv("DEV_FORCE_IS_EVALS") == "true" func inc(x int) string { @@ -86,7 +87,9 @@ func main() { if DEV_DISABLE_ACTIVE_FILTERS { logging.Logger.WithFields(logrus.Fields{"method": "main init"}).Warning("Dev disable active filters is set!") } - + if DEV_FORCE_IS_EBOARD { + logging.Logger.WithFields(logrus.Fields{"method": "main init"}).Warning("Dev force eboard is set!") + } if DEV_FORCE_IS_EVALS { logging.Logger.WithFields(logrus.Fields{"method": "main init"}).Warning("Dev force evals is set!") } @@ -164,7 +167,7 @@ func main() { c.HTML(http.StatusOK, "create.tmpl", gin.H{ "Username": claims.UserInfo.Username, "FullName": claims.UserInfo.FullName, - "IsEvals": isEvals(claims.UserInfo), + "IsEboard": isEboard(claims.UserInfo), }) })) @@ -225,7 +228,7 @@ func main() { poll.Options = []string{"Pass", "Fail", "Abstain"} } if poll.Gatekeep { - if !isEvals(claims.UserInfo) { + if !isEboard(claims.UserInfo) { c.HTML(http.StatusForbidden, "unauthorized.tmpl", gin.H{ "Username": claims.UserInfo.Username, "FullName": claims.UserInfo.FullName, @@ -554,6 +557,11 @@ func main() { r.Run() } +// isEboard determines if the current user is on eboard, allowing for a dev mode override +func isEboard(user cshAuth.CSHUserInfo) bool { + return DEV_FORCE_IS_EBOARD || slices.Contains(user.Groups, "eboard") +} + // isEvals determines if the current user is evals, allowing for a dev mode override func isEvals(user cshAuth.CSHUserInfo) bool { return DEV_FORCE_IS_EVALS || slices.Contains(user.Groups, "eboard-evaluations") diff --git a/templates/create.tmpl b/templates/create.tmpl index e4162a2..41eacab 100644 --- a/templates/create.tmpl +++ b/templates/create.tmpl @@ -73,7 +73,7 @@ > Hide Results Until Vote is Complete - {{ if .IsEvals }} + {{ if .IsEboard }}