diff --git a/router/modpanel.go b/router/modpanel.go index 681e72b8..525e0123 100644 --- a/router/modpanel.go +++ b/router/modpanel.go @@ -52,7 +52,6 @@ func IndexModPanel(w http.ResponseWriter, r *http.Request) { users, _ := userService.RetrieveUsersForAdmin(offset, 0) comments, _ := commentService.GetAllComments(offset, 0, "", "") torrentReports, _, _ := reportService.GetAllTorrentReports(offset, 0) - fmt.Println(torrentReports) languages.SetTranslationFromRequest(panelIndex, r, "en-us") htv := PanelIndexVbs{torrents, torrentReports, users, comments, NewSearchForm(), currentUser, r.URL} @@ -243,6 +242,7 @@ func CommentDeleteModPanel(w http.ResponseWriter, r *http.Request) { http.Error(w, "admins only", http.StatusForbidden) } } + func TorrentDeleteModPanel(w http.ResponseWriter, r *http.Request) { currentUser := GetUser(r) id := r.URL.Query().Get("id") @@ -262,3 +262,19 @@ func TorrentDeleteModPanel(w http.ResponseWriter, r *http.Request) { http.Error(w, "admins only", http.StatusForbidden) } } + +func TorrentReportDeleteModPanel(w http.ResponseWriter, r *http.Request) { + currentUser := GetUser(r) + if userPermission.HasAdmin(currentUser) { + id := r.URL.Query().Get("id") + fmt.Println(id) + idNum, _ := strconv.ParseUint(id, 10, 64) + _ = form.NewErrors() + _, _ = reportService.DeleteTorrentReport(uint(idNum)) + + url, _ := Router.Get("mod_trlist").URL() + http.Redirect(w, r, url.String()+"?deleted", http.StatusSeeOther) + } else { + http.Error(w, "admins only", http.StatusForbidden) + } +} diff --git a/router/router.go b/router/router.go index da317cec..ffdc26ef 100755 --- a/router/router.go +++ b/router/router.go @@ -49,6 +49,7 @@ func init() { gzipTorrentPostEditModPanel := handlers.CompressHandler(http.HandlerFunc(TorrentPostEditModPanel)) gzipCommentDeleteModPanel := handlers.CompressHandler(http.HandlerFunc(CommentDeleteModPanel)) gzipTorrentDeleteModPanel := handlers.CompressHandler(http.HandlerFunc(TorrentDeleteModPanel)) + gzipTorrentReportDeleteModPanel := handlers.CompressHandler(http.HandlerFunc(TorrentReportDeleteModPanel)) //gzipTorrentReportCreateHandler := handlers.CompressHandler(http.HandlerFunc(CreateTorrentReportHandler)) //gzipTorrentReportDeleteHandler := handlers.CompressHandler(http.HandlerFunc(DeleteTorrentReportHandler)) @@ -88,14 +89,17 @@ func init() { Router.Handle("/mod", gzipIndexModPanel).Name("mod_index") Router.Handle("/mod/torrents", gzipTorrentsListPanel).Name("mod_tlist") Router.Handle("/mod/torrents/{page}", gzipTorrentsListPanel).Name("mod_tlist_page") + Router.Handle("/mod/reports", gzipTorrentReportListPanel).Name("mod_trlist") + Router.Handle("/mod/reports/{page}", gzipTorrentReportListPanel).Name("mod_trlist_page") Router.Handle("/mod/users", gzipUsersListPanel).Name("mod_ulist") Router.Handle("/mod/users/{page}", gzipUsersListPanel).Name("mod_ulist_page") Router.Handle("/mod/comments", gzipCommentsListPanel).Name("mod_clist") Router.Handle("/mod/comments/{page}", gzipCommentsListPanel).Name("mod_clist_page") Router.Handle("/mod/comment", gzipCommentsListPanel).Name("mod_cedit") // TODO - Router.Handle("/mod/torrent/", gzipTorrentEditModPanel).Name("mod_tedit") - Router.Handle("/mod/torrent/", gzipTorrentPostEditModPanel).Name("mod_ptedit") + Router.Handle("/mod/torrent/", gzipTorrentEditModPanel).Name("mod_tedit").Methods("GET") + Router.Handle("/mod/torrent/", gzipTorrentPostEditModPanel).Name("mod_ptedit").Methods("POST") Router.Handle("/mod/torrent/delete", gzipTorrentDeleteModPanel).Name("mod_tdelete") + Router.Handle("/mod/report/delete", gzipTorrentReportDeleteModPanel).Name("mod_trdelete") Router.Handle("/mod/comment/delete", gzipCommentDeleteModPanel).Name("mod_cdelete") //reporting a torrent @@ -107,8 +111,6 @@ func init() { // TODO Allow only moderators to access /moderation/* //Router.Handle("/moderation/report/delete", gzipTorrentReportDeleteHandler).Name("torrent_report_delete").Methods("POST") //Router.Handle("/moderation/torrent/delete", gzipTorrentDeleteHandler).Name("torrent_delete").Methods("POST") - Router.Handle("/mod/reports", gzipTorrentReportListPanel).Name("mod_trlist").Methods("GET") - Router.Handle("/mod/reports/{page}", gzipTorrentReportListPanel).Name("mod_trlist_page").Methods("GET") Router.NotFoundHandler = http.HandlerFunc(NotFoundHandler) } diff --git a/templates/admin/panelindex.html b/templates/admin/panelindex.html index 651feb23..6dcef57b 100644 --- a/templates/admin/panelindex.html +++ b/templates/admin/panelindex.html @@ -18,7 +18,7 @@ {{ range .TorrentReports}}