Update torrents.go
Cette révision appartient à :
Parent
a6ca5e5b88
révision
71fddc2d39
1 fichiers modifiés avec 7 ajouts et 20 suppressions
|
@ -121,24 +121,11 @@ func TorrentPostEditModPanel(c *gin.Context) {
|
||||||
// TorrentDeleteModPanel : Controller for deleting a torrent
|
// TorrentDeleteModPanel : Controller for deleting a torrent
|
||||||
func TorrentDeleteModPanel(c *gin.Context) {
|
func TorrentDeleteModPanel(c *gin.Context) {
|
||||||
id, _ := strconv.ParseInt(c.PostForm("id"), 10, 32)
|
id, _ := strconv.ParseInt(c.PostForm("id"), 10, 32)
|
||||||
definitely := c.Request.URL.Query()["definitely"]
|
|
||||||
|
|
||||||
var returnRoute = "/mod/torrents"
|
var returnRoute = "/mod/torrents"
|
||||||
torrent, errFind := torrents.FindByID(uint(id))
|
torrent, errFind := torrents.FindByID(uint(id))
|
||||||
if errFind == nil {
|
if errFind == nil {
|
||||||
var err error
|
var err error
|
||||||
if definitely != nil {
|
|
||||||
_, _, err = torrent.DefinitelyDelete()
|
|
||||||
|
|
||||||
//delete reports of torrent
|
|
||||||
query := &search.Query{}
|
|
||||||
query.Append("torrent_id", id)
|
|
||||||
reports, _, _ := reports.FindOrderBy(query, "", 0, 0)
|
|
||||||
for _, report := range reports {
|
|
||||||
report.Delete(true)
|
|
||||||
}
|
|
||||||
returnRoute = "/mod/torrents/deleted"
|
|
||||||
} else {
|
|
||||||
_, _, err = torrent.Delete(false)
|
_, _, err = torrent.Delete(false)
|
||||||
|
|
||||||
//delete reports of torrent
|
//delete reports of torrent
|
||||||
|
@ -146,9 +133,9 @@ func TorrentDeleteModPanel(c *gin.Context) {
|
||||||
query.Append("torrent_id", id)
|
query.Append("torrent_id", id)
|
||||||
reports, _, _ := reports.FindOrderBy(query, "", 0, 0)
|
reports, _, _ := reports.FindOrderBy(query, "", 0, 0)
|
||||||
for _, report := range reports {
|
for _, report := range reports {
|
||||||
report.Delete(false)
|
report.Delete()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if torrent.Uploader == nil {
|
if torrent.Uploader == nil {
|
||||||
torrent.Uploader = &models.User{}
|
torrent.Uploader = &models.User{}
|
||||||
|
|
Référencer dans un nouveau ticket