reports are deleted with torrents
Cette révision appartient à :
Parent
8373bce02f
révision
755a426931
2 fichiers modifiés avec 11 ajouts et 1 suppressions
|
@ -3,6 +3,7 @@
|
||||||
package router
|
package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -10,6 +11,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/ewhal/nyaa/model"
|
"github.com/ewhal/nyaa/model"
|
||||||
|
"github.com/ewhal/nyaa/service"
|
||||||
"github.com/ewhal/nyaa/service/comment"
|
"github.com/ewhal/nyaa/service/comment"
|
||||||
"github.com/ewhal/nyaa/service/report"
|
"github.com/ewhal/nyaa/service/report"
|
||||||
"github.com/ewhal/nyaa/service/torrent"
|
"github.com/ewhal/nyaa/service/torrent"
|
||||||
|
@ -50,6 +52,7 @@ func IndexModPanel(w http.ResponseWriter, r *http.Request) {
|
||||||
users, _ := userService.RetrieveUsersForAdmin(offset, 0)
|
users, _ := userService.RetrieveUsersForAdmin(offset, 0)
|
||||||
comments, _ := commentService.GetAllComments(offset, 0, "", "")
|
comments, _ := commentService.GetAllComments(offset, 0, "", "")
|
||||||
torrentReports, _, _ := reportService.GetAllTorrentReports(offset, 0)
|
torrentReports, _, _ := reportService.GetAllTorrentReports(offset, 0)
|
||||||
|
fmt.Println(torrentReports)
|
||||||
|
|
||||||
languages.SetTranslationFromRequest(panelIndex, r, "en-us")
|
languages.SetTranslationFromRequest(panelIndex, r, "en-us")
|
||||||
htv := PanelIndexVbs{torrents, torrentReports, users, comments, NewSearchForm(), currentUser, r.URL}
|
htv := PanelIndexVbs{torrents, torrentReports, users, comments, NewSearchForm(), currentUser, r.URL}
|
||||||
|
@ -246,6 +249,13 @@ func TorrentDeleteModPanel(w http.ResponseWriter, r *http.Request) {
|
||||||
if userPermission.HasAdmin(currentUser) {
|
if userPermission.HasAdmin(currentUser) {
|
||||||
_ = form.NewErrors()
|
_ = form.NewErrors()
|
||||||
_, _ = torrentService.DeleteTorrent(id)
|
_, _ = torrentService.DeleteTorrent(id)
|
||||||
|
|
||||||
|
//delete reports of torrent
|
||||||
|
whereParams := serviceBase.CreateWhereParams("torrent_id = ?", id)
|
||||||
|
reports, _, _ := reportService.GetTorrentReportsOrderBy(&whereParams, "", 0, 0)
|
||||||
|
for _, report := range reports {
|
||||||
|
reportService.DeleteTorrentReport(report.ID)
|
||||||
|
}
|
||||||
url, _ := Router.Get("mod_tlist").URL()
|
url, _ := Router.Get("mod_tlist").URL()
|
||||||
http.Redirect(w, r, url.String()+"?deleted", http.StatusSeeOther)
|
http.Redirect(w, r, url.String()+"?deleted", http.StatusSeeOther)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -19,7 +19,7 @@ func CreateTorrentReport(torrentReport model.TorrentReport) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteTorrentReport(id int) (error, int) {
|
func DeleteTorrentReport(id uint) (error, int) {
|
||||||
var torrentReport model.TorrentReport
|
var torrentReport model.TorrentReport
|
||||||
if db.ORM.First(&torrentReport, id).RecordNotFound() {
|
if db.ORM.First(&torrentReport, id).RecordNotFound() {
|
||||||
return errors.New("Trying to delete a torrent report that does not exists."), http.StatusNotFound
|
return errors.New("Trying to delete a torrent report that does not exists."), http.StatusNotFound
|
||||||
|
|
Référencer dans un nouveau ticket