|
|
@ -261,7 +261,11 @@ func (app *application) newMotionSubmit(w http.ResponseWriter, r *http.Request)
|
|
|
|
|
|
|
|
|
|
|
|
app.jobScheduler.Reschedule(JobIDCloseDecisions, JobIDRemindVoters)
|
|
|
|
app.jobScheduler.Reschedule(JobIDCloseDecisions, JobIDRemindVoters)
|
|
|
|
|
|
|
|
|
|
|
|
app.sessionManager.Put(r.Context(), "flash", fmt.Sprintf("Started new motion %s: %s", decision.Tag, decision.Title))
|
|
|
|
app.addFlash(r, &FlashMessage{
|
|
|
|
|
|
|
|
Variant: flashSuccess,
|
|
|
|
|
|
|
|
Title: "New motion started",
|
|
|
|
|
|
|
|
Message: fmt.Sprintf("Started new motion %s: %s", decision.Tag, decision.Title),
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
http.Redirect(w, r, "/motions/", http.StatusSeeOther)
|
|
|
|
http.Redirect(w, r, "/motions/", http.StatusSeeOther)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -357,11 +361,11 @@ func (app *application) editMotionSubmit(w http.ResponseWriter, r *http.Request)
|
|
|
|
|
|
|
|
|
|
|
|
app.jobScheduler.Reschedule(JobIDCloseDecisions, JobIDRemindVoters)
|
|
|
|
app.jobScheduler.Reschedule(JobIDCloseDecisions, JobIDRemindVoters)
|
|
|
|
|
|
|
|
|
|
|
|
app.sessionManager.Put(
|
|
|
|
app.addFlash(r, &FlashMessage{
|
|
|
|
r.Context(),
|
|
|
|
Variant: flashInfo,
|
|
|
|
"flash",
|
|
|
|
Title: "Motion modified",
|
|
|
|
fmt.Sprintf("The motion %s has been modified!", decision.Tag),
|
|
|
|
Message: fmt.Sprintf("The motion %s has been modified!", decision.Tag),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
http.Redirect(w, r, "/motions/", http.StatusSeeOther)
|
|
|
|
http.Redirect(w, r, "/motions/", http.StatusSeeOther)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -412,11 +416,11 @@ func (app *application) withdrawMotionSubmit(w http.ResponseWriter, r *http.Requ
|
|
|
|
|
|
|
|
|
|
|
|
app.jobScheduler.Reschedule(JobIDCloseDecisions, JobIDRemindVoters)
|
|
|
|
app.jobScheduler.Reschedule(JobIDCloseDecisions, JobIDRemindVoters)
|
|
|
|
|
|
|
|
|
|
|
|
app.sessionManager.Put(
|
|
|
|
app.addFlash(r, &FlashMessage{
|
|
|
|
r.Context(),
|
|
|
|
Variant: flashWarning,
|
|
|
|
"flash",
|
|
|
|
Title: "Motion withdrawn",
|
|
|
|
fmt.Sprintf("Motion %s has been withdrawn!", motion.Tag),
|
|
|
|
Message: fmt.Sprintf("The motion %s has been withdrawn!", motion.Tag),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
http.Redirect(w, r, "/motions/", http.StatusSeeOther)
|
|
|
|
http.Redirect(w, r, "/motions/", http.StatusSeeOther)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -490,11 +494,11 @@ func (app *application) voteSubmit(w http.ResponseWriter, r *http.Request) {
|
|
|
|
Decision: motion, User: user, Choice: choice,
|
|
|
|
Decision: motion, User: user, Choice: choice,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
app.sessionManager.Put(
|
|
|
|
app.addFlash(r, &FlashMessage{
|
|
|
|
r.Context(),
|
|
|
|
Variant: flashSuccess,
|
|
|
|
"flash",
|
|
|
|
Title: "Vote registered",
|
|
|
|
fmt.Sprintf("Your vote for motion %s has been registered.", motion.Tag),
|
|
|
|
Message: fmt.Sprintf("Your vote for motion %s has been registered.", motion.Tag),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
http.Redirect(w, r, "/motions/", http.StatusSeeOther)
|
|
|
|
http.Redirect(w, r, "/motions/", http.StatusSeeOther)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -598,11 +602,15 @@ func (app *application) proxyVoteSubmit(w http.ResponseWriter, r *http.Request)
|
|
|
|
Decision: motion, User: user, Voter: voter, Choice: form.Choice, Justification: form.Justification,
|
|
|
|
Decision: motion, User: user, Voter: voter, Choice: form.Choice, Justification: form.Justification,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
app.sessionManager.Put(
|
|
|
|
app.addFlash(r, &FlashMessage{
|
|
|
|
r.Context(),
|
|
|
|
Variant: flashSuccess,
|
|
|
|
"flash",
|
|
|
|
Title: "Proxy vote registered",
|
|
|
|
fmt.Sprintf("Your proxy vote for %s for motion %s has been registered.", voter.Name, motion.Tag),
|
|
|
|
Message: fmt.Sprintf(
|
|
|
|
)
|
|
|
|
"Your proxy vote for %s for motion %s has been registered.",
|
|
|
|
|
|
|
|
voter.Name,
|
|
|
|
|
|
|
|
motion.Tag,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
http.Redirect(w, r, "/motions/", http.StatusSeeOther)
|
|
|
|
http.Redirect(w, r, "/motions/", http.StatusSeeOther)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -735,11 +743,11 @@ func (app *application) editUserSubmit(w http.ResponseWriter, r *http.Request) {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
app.sessionManager.Put(
|
|
|
|
app.addFlash(r, &FlashMessage{
|
|
|
|
r.Context(),
|
|
|
|
Variant: flashInfo,
|
|
|
|
"flash",
|
|
|
|
Title: "User modified",
|
|
|
|
fmt.Sprintf("User %s has been modified.", userToEdit.Name),
|
|
|
|
Message: fmt.Sprintf("User %s has been modified.", userToEdit.Name),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
http.Redirect(w, r, "/users/", http.StatusSeeOther)
|
|
|
|
http.Redirect(w, r, "/users/", http.StatusSeeOther)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -835,11 +843,15 @@ func (app *application) userAddEmailSubmit(w http.ResponseWriter, r *http.Reques
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
app.sessionManager.Put(
|
|
|
|
app.addFlash(r, &FlashMessage{
|
|
|
|
r.Context(),
|
|
|
|
Variant: flashSuccess,
|
|
|
|
"flash",
|
|
|
|
Title: "Email address added",
|
|
|
|
fmt.Sprintf("Added email address %s for user %s", form.EmailAddress, userToEdit.Name),
|
|
|
|
Message: fmt.Sprintf(
|
|
|
|
)
|
|
|
|
"Added email address %s for user %s",
|
|
|
|
|
|
|
|
form.EmailAddress,
|
|
|
|
|
|
|
|
userToEdit.Name,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
http.Redirect(w, r, fmt.Sprintf("/users/%d/", userToEdit.ID), http.StatusSeeOther)
|
|
|
|
http.Redirect(w, r, fmt.Sprintf("/users/%d/", userToEdit.ID), http.StatusSeeOther)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -860,7 +872,7 @@ func (app *application) newUserForm(_ http.ResponseWriter, _ *http.Request) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (app *application) newUserSubmit(_ http.ResponseWriter, _ *http.Request) {
|
|
|
|
func (app *application) newUserSubmit(_ http.ResponseWriter, _ *http.Request) {
|
|
|
|
// TODO: implement userDeleteEmailSubmit
|
|
|
|
// TODO: implement newUserSubmit
|
|
|
|
panic("not implemented")
|
|
|
|
panic("not implemented")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -928,11 +940,11 @@ func (app *application) deleteUserSubmit(w http.ResponseWriter, r *http.Request)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
app.sessionManager.Put(
|
|
|
|
app.addFlash(r, &FlashMessage{
|
|
|
|
r.Context(),
|
|
|
|
Variant: flashWarning,
|
|
|
|
"flash",
|
|
|
|
Title: "User deleted",
|
|
|
|
fmt.Sprintf("User %s has been deleted.", userToDelete.Name),
|
|
|
|
Message: fmt.Sprintf("User %s has been deleted.", userToDelete.Name),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
http.Redirect(w, r, "/users/", http.StatusSeeOther)
|
|
|
|
http.Redirect(w, r, "/users/", http.StatusSeeOther)
|
|
|
|
}
|
|
|
|
}
|
|
|
|