summaryrefslogtreecommitdiff
path: root/boardvoting.go
diff options
context:
space:
mode:
Diffstat (limited to 'boardvoting.go')
-rw-r--r--boardvoting.go32
1 files changed, 13 insertions, 19 deletions
diff --git a/boardvoting.go b/boardvoting.go
index 8ad5438..367179f 100644
--- a/boardvoting.go
+++ b/boardvoting.go
@@ -83,7 +83,7 @@ type motionParameters struct {
}
type motionListParameters struct {
- Page int64
+ Page int64
Flags struct {
Confirmed, Withdraw, Unvoted bool
}
@@ -136,21 +136,13 @@ func motionListHandler(w http.ResponseWriter, r *http.Request) {
session.Save(r, w)
templateContext.Params = &params
- if params.Flags.Unvoted && templateContext.Voter != nil {
- if templateContext.Decisions, err = FindVotersUnvotedDecisionsForDisplayOnPage(
- params.Page, templateContext.Voter); err != nil {
- http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
- return
- }
- } else {
- if templateContext.Decisions, err = FindDecisionsForDisplayOnPage(params.Page); err != nil {
- http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
- return
- }
+ if templateContext.Decisions, err = FindDecisionsForDisplayOnPage(params.Page, params.Flags.Unvoted, templateContext.Voter); err != nil {
+ http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
+ return
}
if len(templateContext.Decisions) > 0 {
- olderExists, err := templateContext.Decisions[len(templateContext.Decisions)-1].OlderExists()
+ olderExists, err := templateContext.Decisions[len(templateContext.Decisions)-1].OlderExists(params.Flags.Unvoted, templateContext.Voter)
if err != nil {
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
@@ -363,7 +355,7 @@ func newMotionHandler(w http.ResponseWriter, r *http.Request) {
session.AddFlash("The motion has been proposed!")
session.Save(r, w)
- http.Redirect(w, r, "/motions/", http.StatusTemporaryRedirect)
+ http.Redirect(w, r, "/motions/", http.StatusMovedPermanently)
}
return
@@ -384,6 +376,7 @@ type Config struct {
ServerCert string `yaml:"server_certificate"`
ServerKey string `yaml:"server_key"`
CookieSecret string `yaml:"cookie_secret"`
+ BaseURL string `yaml:"base_url"`
}
func init() {
@@ -406,16 +399,17 @@ func init() {
}
store = sessions.NewCookieStore(cookieSecret)
logger.Println("read configuration")
-}
-func main() {
- logger.Printf("CAcert Board Voting version %s, build %s\n", version, build)
-
- var err error
db, err = sqlx.Open("sqlite3", config.DatabaseFile)
if err != nil {
logger.Fatal(err)
}
+ logger.Println("opened database connection")
+}
+
+func main() {
+ logger.Printf("CAcert Board Voting version %s, build %s\n", version, build)
+
defer db.Close()
http.Handle("/motions/", http.StripPrefix("/motions/", motionsHandler{}))