Refactor new books into moderate submissions
This commit is contained in:
parent
897071e85d
commit
4efaaadbd2
8 changed files with 162 additions and 153 deletions
|
@ -9,7 +9,6 @@ import (
|
|||
"encoding/base64"
|
||||
"mime/multipart"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/meskio/epubgo"
|
||||
"gitlab.com/trantor/trantor/lib/database"
|
||||
"gitlab.com/trantor/trantor/lib/parser"
|
||||
|
@ -124,42 +123,6 @@ func uploadHandler(h handler) {
|
|||
h.load("upload", data)
|
||||
}
|
||||
|
||||
func submissionHandler(h handler) {
|
||||
var data submissionData
|
||||
var err error
|
||||
|
||||
submissionID := mux.Vars(h.r)["submissionID"]
|
||||
data.SubmissionID = submissionID
|
||||
data.Submissions, err = h.db.GetSubmission(submissionID)
|
||||
if err != nil {
|
||||
log.Error("Can get submission ", submissionID, ": ", err)
|
||||
}
|
||||
data.S = GetStatus(h)
|
||||
data.S.Title = "Submission -- " + data.S.Title
|
||||
h.load("submission", data)
|
||||
}
|
||||
|
||||
type submissionData struct {
|
||||
S Status
|
||||
SubmissionID string
|
||||
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)
|
||||
|
|
Reference in a new issue