|
|
@ -24,8 +24,6 @@ import (
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/julienschmidt/httprouter"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"git.cacert.org/cacert-boardvoting/internal/forms"
|
|
|
|
"git.cacert.org/cacert-boardvoting/internal/forms"
|
|
|
|
|
|
|
|
|
|
|
|
"git.cacert.org/cacert-boardvoting/internal/models"
|
|
|
|
"git.cacert.org/cacert-boardvoting/internal/models"
|
|
|
@ -176,9 +174,7 @@ func (app *application) calculateMotionListOptions(r *http.Request) (*models.Mot
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (app *application) motionDetails(w http.ResponseWriter, r *http.Request) {
|
|
|
|
func (app *application) motionDetails(w http.ResponseWriter, r *http.Request) {
|
|
|
|
params := httprouter.ParamsFromContext(r.Context())
|
|
|
|
motion := app.motionFromRequestParam(w, r)
|
|
|
|
|
|
|
|
|
|
|
|
motion := app.motionFromRequestParam(w, r, params)
|
|
|
|
|
|
|
|
if motion == nil {
|
|
|
|
if motion == nil {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -271,9 +267,7 @@ func (app *application) newMotionSubmit(w http.ResponseWriter, r *http.Request)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (app *application) editMotionForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
func (app *application) editMotionForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
params := httprouter.ParamsFromContext(r.Context())
|
|
|
|
motion := app.motionFromRequestParam(w, r)
|
|
|
|
|
|
|
|
|
|
|
|
motion := app.motionFromRequestParam(w, r, params)
|
|
|
|
|
|
|
|
if motion == nil {
|
|
|
|
if motion == nil {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -292,9 +286,7 @@ func (app *application) editMotionForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (app *application) editMotionSubmit(w http.ResponseWriter, r *http.Request) {
|
|
|
|
func (app *application) editMotionSubmit(w http.ResponseWriter, r *http.Request) {
|
|
|
|
params := httprouter.ParamsFromContext(r.Context())
|
|
|
|
motion := app.motionFromRequestParam(w, r)
|
|
|
|
|
|
|
|
|
|
|
|
motion := app.motionFromRequestParam(w, r, params)
|
|
|
|
|
|
|
|
if motion == nil {
|
|
|
|
if motion == nil {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -371,9 +363,7 @@ func (app *application) editMotionSubmit(w http.ResponseWriter, r *http.Request)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (app *application) withdrawMotionForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
func (app *application) withdrawMotionForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
params := httprouter.ParamsFromContext(r.Context())
|
|
|
|
motion := app.motionFromRequestParam(w, r)
|
|
|
|
|
|
|
|
|
|
|
|
motion := app.motionFromRequestParam(w, r, params)
|
|
|
|
|
|
|
|
if motion == nil {
|
|
|
|
if motion == nil {
|
|
|
|
app.notFound(w)
|
|
|
|
app.notFound(w)
|
|
|
|
|
|
|
|
|
|
|
@ -388,9 +378,7 @@ func (app *application) withdrawMotionForm(w http.ResponseWriter, r *http.Reques
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (app *application) withdrawMotionSubmit(w http.ResponseWriter, r *http.Request) {
|
|
|
|
func (app *application) withdrawMotionSubmit(w http.ResponseWriter, r *http.Request) {
|
|
|
|
params := httprouter.ParamsFromContext(r.Context())
|
|
|
|
motion := app.motionFromRequestParam(w, r)
|
|
|
|
|
|
|
|
|
|
|
|
motion := app.motionFromRequestParam(w, r, params)
|
|
|
|
|
|
|
|
if motion == nil {
|
|
|
|
if motion == nil {
|
|
|
|
app.notFound(w)
|
|
|
|
app.notFound(w)
|
|
|
|
|
|
|
|
|
|
|
@ -426,16 +414,14 @@ func (app *application) withdrawMotionSubmit(w http.ResponseWriter, r *http.Requ
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (app *application) voteForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
func (app *application) voteForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
params := httprouter.ParamsFromContext(r.Context())
|
|
|
|
motion := app.motionFromRequestParam(w, r)
|
|
|
|
|
|
|
|
|
|
|
|
motion := app.motionFromRequestParam(w, r, params)
|
|
|
|
|
|
|
|
if motion == nil {
|
|
|
|
if motion == nil {
|
|
|
|
app.notFound(w)
|
|
|
|
app.notFound(w)
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
choice := app.choiceFromRequestParam(w, params)
|
|
|
|
choice := app.choiceFromRequestParam(w, r)
|
|
|
|
if choice == nil {
|
|
|
|
if choice == nil {
|
|
|
|
app.notFound(w)
|
|
|
|
app.notFound(w)
|
|
|
|
|
|
|
|
|
|
|
@ -454,14 +440,12 @@ func (app *application) voteForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (app *application) voteSubmit(w http.ResponseWriter, r *http.Request) {
|
|
|
|
func (app *application) voteSubmit(w http.ResponseWriter, r *http.Request) {
|
|
|
|
params := httprouter.ParamsFromContext(r.Context())
|
|
|
|
motion := app.motionFromRequestParam(w, r)
|
|
|
|
|
|
|
|
|
|
|
|
motion := app.motionFromRequestParam(w, r, params)
|
|
|
|
|
|
|
|
if motion == nil {
|
|
|
|
if motion == nil {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
choice := app.choiceFromRequestParam(w, params)
|
|
|
|
choice := app.choiceFromRequestParam(w, r)
|
|
|
|
if choice == nil {
|
|
|
|
if choice == nil {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -504,9 +488,7 @@ func (app *application) voteSubmit(w http.ResponseWriter, r *http.Request) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (app *application) proxyVoteForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
func (app *application) proxyVoteForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
params := httprouter.ParamsFromContext(r.Context())
|
|
|
|
motion := app.motionFromRequestParam(w, r)
|
|
|
|
|
|
|
|
|
|
|
|
motion := app.motionFromRequestParam(w, r, params)
|
|
|
|
|
|
|
|
if motion == nil {
|
|
|
|
if motion == nil {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -530,9 +512,7 @@ func (app *application) proxyVoteForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (app *application) proxyVoteSubmit(w http.ResponseWriter, r *http.Request) {
|
|
|
|
func (app *application) proxyVoteSubmit(w http.ResponseWriter, r *http.Request) {
|
|
|
|
params := httprouter.ParamsFromContext(r.Context())
|
|
|
|
motion := app.motionFromRequestParam(w, r)
|
|
|
|
|
|
|
|
|
|
|
|
motion := app.motionFromRequestParam(w, r, params)
|
|
|
|
|
|
|
|
if motion == nil {
|
|
|
|
if motion == nil {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -635,9 +615,7 @@ func (app *application) userList(w http.ResponseWriter, r *http.Request) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (app *application) editUserForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
func (app *application) editUserForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
params := httprouter.ParamsFromContext(r.Context())
|
|
|
|
userToEdit := app.userFromRequestParam(w, r, app.users.WithRoles(), app.users.WithEmailAddresses())
|
|
|
|
|
|
|
|
|
|
|
|
userToEdit := app.userFromRequestParam(w, r, params, app.users.WithRoles(), app.users.WithEmailAddresses())
|
|
|
|
|
|
|
|
if userToEdit == nil {
|
|
|
|
if userToEdit == nil {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -676,9 +654,7 @@ func (app *application) editUserForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (app *application) editUserSubmit(w http.ResponseWriter, r *http.Request) {
|
|
|
|
func (app *application) editUserSubmit(w http.ResponseWriter, r *http.Request) {
|
|
|
|
params := httprouter.ParamsFromContext(r.Context())
|
|
|
|
userToEdit := app.userFromRequestParam(w, r, app.users.WithRoles(), app.users.WithEmailAddresses())
|
|
|
|
|
|
|
|
|
|
|
|
userToEdit := app.userFromRequestParam(w, r, params, app.users.WithRoles(), app.users.WithEmailAddresses())
|
|
|
|
|
|
|
|
if userToEdit == nil {
|
|
|
|
if userToEdit == nil {
|
|
|
|
app.notFound(w)
|
|
|
|
app.notFound(w)
|
|
|
|
|
|
|
|
|
|
|
@ -753,9 +729,7 @@ func (app *application) editUserSubmit(w http.ResponseWriter, r *http.Request) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (app *application) userAddEmailForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
func (app *application) userAddEmailForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
params := httprouter.ParamsFromContext(r.Context())
|
|
|
|
userToEdit := app.userFromRequestParam(w, r, app.users.WithEmailAddresses())
|
|
|
|
|
|
|
|
|
|
|
|
userToEdit := app.userFromRequestParam(w, r, params, app.users.WithEmailAddresses())
|
|
|
|
|
|
|
|
if userToEdit == nil {
|
|
|
|
if userToEdit == nil {
|
|
|
|
app.notFound(w)
|
|
|
|
app.notFound(w)
|
|
|
|
|
|
|
|
|
|
|
@ -780,9 +754,7 @@ func (app *application) userAddEmailForm(w http.ResponseWriter, r *http.Request)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (app *application) userAddEmailSubmit(w http.ResponseWriter, r *http.Request) {
|
|
|
|
func (app *application) userAddEmailSubmit(w http.ResponseWriter, r *http.Request) {
|
|
|
|
params := httprouter.ParamsFromContext(r.Context())
|
|
|
|
userToEdit := app.userFromRequestParam(w, r, app.users.WithEmailAddresses())
|
|
|
|
|
|
|
|
|
|
|
|
userToEdit := app.userFromRequestParam(w, r, params, app.users.WithEmailAddresses())
|
|
|
|
|
|
|
|
if userToEdit == nil {
|
|
|
|
if userToEdit == nil {
|
|
|
|
app.notFound(w)
|
|
|
|
app.notFound(w)
|
|
|
|
|
|
|
|
|
|
|
@ -970,7 +942,7 @@ func (app *application) newUserSubmit(_ http.ResponseWriter, _ *http.Request) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (app *application) deleteUserForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
func (app *application) deleteUserForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
userToDelete := app.userFromRequestParam(w, r, httprouter.ParamsFromContext(r.Context()), app.users.CanDelete())
|
|
|
|
userToDelete := app.userFromRequestParam(w, r, app.users.CanDelete())
|
|
|
|
if userToDelete == nil {
|
|
|
|
if userToDelete == nil {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -991,7 +963,7 @@ func (app *application) deleteUserForm(w http.ResponseWriter, r *http.Request) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (app *application) deleteUserSubmit(w http.ResponseWriter, r *http.Request) {
|
|
|
|
func (app *application) deleteUserSubmit(w http.ResponseWriter, r *http.Request) {
|
|
|
|
userToDelete := app.userFromRequestParam(w, r, httprouter.ParamsFromContext(r.Context()), app.users.CanDelete())
|
|
|
|
userToDelete := app.userFromRequestParam(w, r, app.users.CanDelete())
|
|
|
|
if userToDelete == nil {
|
|
|
|
if userToDelete == nil {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|