Add comments to submissions

This commit is contained in:
Las Zenow 2018-04-07 23:42:41 +00:00
parent 8d126fbe7a
commit 8bcff3c826
8 changed files with 97 additions and 30 deletions

View file

@ -144,6 +144,21 @@ type submissionData struct {
Submissions []database.Submission
}
func submissionCommentHandler(h handler) {
submissionID := mux.Vars(h.r)["submissionID"]
bookID := mux.Vars(h.r)["id"]
comment := h.r.FormValue("comment")
err := h.db.UpdateSubmissionComment(submissionID, bookID, comment)
if err != nil {
log.Error("Adding comment (submission: ", submissionID, ", book: ", bookID, ") <", comment, ">: ", err)
h.sess.Notify("Error adding a comment!", "Can't add the comment rigt now. Try again later or report it to the site admins", "error")
} else {
h.sess.Notify("Comment added!", "", "success")
}
http.Redirect(h.w, h.r, "/submission/"+submissionID, http.StatusFound)
}
func genID() string {
b := make([]byte, 12)
rand.Read(b)