diff options
Diffstat (limited to 'pkg/app/handler/glsa')
-rw-r--r-- | pkg/app/handler/glsa/comments.go | 7 | ||||
-rw-r--r-- | pkg/app/handler/glsa/edit.go | 5 | ||||
-rw-r--r-- | pkg/app/handler/glsa/view.go | 5 |
3 files changed, 11 insertions, 6 deletions
diff --git a/pkg/app/handler/glsa/comments.go b/pkg/app/handler/glsa/comments.go index 73d11c2..1381984 100644 --- a/pkg/app/handler/glsa/comments.go +++ b/pkg/app/handler/glsa/comments.go @@ -26,16 +26,11 @@ func AddComment(w http.ResponseWriter, r *http.Request) { return } - if !user.CanEditCVEs() { - w.Write([]byte("err")) - return - } - id, comment, commentType, err := getParams(r) newComment, err := AddNewCommment(id, user, comment, commentType) - if err != nil { + if err != nil || comment == "" { logger.Info.Println("Err") logger.Info.Println(err) w.Write([]byte("err")) diff --git a/pkg/app/handler/glsa/edit.go b/pkg/app/handler/glsa/edit.go index c89e68f..6c6bb1e 100644 --- a/pkg/app/handler/glsa/edit.go +++ b/pkg/app/handler/glsa/edit.go @@ -9,6 +9,7 @@ import ( "glsamaker/pkg/models/bugzilla" "glsamaker/pkg/models/gpackage" "net/http" + "sort" "strconv" "time" ) @@ -180,6 +181,10 @@ func Edit(w http.ResponseWriter, r *http.Request) { currentGlsa.ComputeStatus(user) currentGlsa.ComputeCommentBadges() + // sort the comments by creation date + sort.Slice(currentGlsa.Comments, func(p, q int) bool { + return currentGlsa.Comments[p].Date.Before(currentGlsa.Comments[q].Date) }) + glsaCount, err := connection.DB.Model((*models.Glsa)(nil)).Count() renderEditTemplate(w, user, currentGlsa, int64(glsaCount)) diff --git a/pkg/app/handler/glsa/view.go b/pkg/app/handler/glsa/view.go index 945af2d..9b89573 100644 --- a/pkg/app/handler/glsa/view.go +++ b/pkg/app/handler/glsa/view.go @@ -6,6 +6,7 @@ import ( "glsamaker/pkg/database/connection" "glsamaker/pkg/models" "net/http" + "sort" "strconv" ) @@ -43,6 +44,10 @@ func View(w http.ResponseWriter, r *http.Request) { glsa.ComputeStatus(user) glsa.ComputeCommentBadges() + // sort the comments by creation date + sort.Slice(glsa.Comments, func(p, q int) bool { + return glsa.Comments[p].Date.Before(glsa.Comments[q].Date) }) + glsaCount, err := connection.DB.Model((*models.Glsa)(nil)).Count() renderViewTemplate(w, user, glsa, int64(glsaCount)) |