diff --git a/model/comment.go b/model/comment.go index 26659329..703d287f 100644 --- a/model/comment.go +++ b/model/comment.go @@ -11,6 +11,7 @@ type Comment struct { Content string `gorm:"column:content"` CreatedAt time.Time `gorm:"column:created_at"` UpdatedAt time.Time `gorm:"column:updated_at"` + DeletedAt *time.Time Torrent *Torrent `gorm:"ForeignKey:torrent_id"` User *User `gorm:"ForeignKey:user_id"` diff --git a/model/torrent.go b/model/torrent.go index bda36357..de9daa8a 100644 --- a/model/torrent.go +++ b/model/torrent.go @@ -34,6 +34,7 @@ type Torrent struct { Filesize int64 `gorm:"column:filesize"` Description string `gorm:"column:description"` WebsiteLink string `gorm:"column:website_link"` + DeletedAt *time.Time Uploader *User `gorm:"ForeignKey:UploaderId"` OldComments []OldComment `gorm:"ForeignKey:torrent_id"` diff --git a/router/modpanel.go b/router/modpanel.go index 46bb90e9..6b2ad5af 100644 --- a/router/modpanel.go +++ b/router/modpanel.go @@ -142,7 +142,7 @@ func CommentDeleteModPanel(w http.ResponseWriter, r *http.Request) { if userPermission.HasAdmin(currentUser) { _ = form.NewErrors() _, _ = userService.DeleteComment(id) - url, _ := Router.Get("mod_comment_list").URL() + url, _ := Router.Get("mod_clist").URL() http.Redirect(w, r, url.String()+"?deleted", http.StatusSeeOther) } else { http.Error(w, "admins only", http.StatusForbidden) @@ -154,7 +154,7 @@ func TorrentDeleteModPanel(w http.ResponseWriter, r *http.Request) { if userPermission.HasAdmin(currentUser) { _ = form.NewErrors() _, _ = torrentService.DeleteTorrent(id) - url, _ := Router.Get("mod_torrent_list").URL() + url, _ := Router.Get("mod_tlist").URL() http.Redirect(w, r, url.String()+"?deleted", http.StatusSeeOther) } else { http.Error(w, "admins only", http.StatusForbidden) diff --git a/service/torrent/torrent.go b/service/torrent/torrent.go index 7f204ced..a099bea4 100644 --- a/service/torrent/torrent.go +++ b/service/torrent/torrent.go @@ -97,6 +97,7 @@ func getTorrentsOrderBy(parameters *WhereParams, orderBy string, limit int, offs torrents []model.Torrent, count int, err error, ) { var conditionArray []string + conditionArray = append(conditionArray, "deleted_at IS NULL") if strings.HasPrefix(orderBy, "filesize") { // torrents w/ NULL filesize fuck up the sorting on Postgres conditionArray = append(conditionArray, "filesize IS NOT NULL") diff --git a/templates/admin/commentlist.html b/templates/admin/commentlist.html index c6827730..dd74f791 100644 --- a/templates/admin/commentlist.html +++ b/templates/admin/commentlist.html @@ -2,7 +2,7 @@ {{ range .Comments}} - + {{end}}
{{ .Content }}Delete
{{ .Content }}Delete
{{end}} diff --git a/templates/admin/torrentlist.html b/templates/admin/torrentlist.html index c9569a1a..d67290ac 100644 --- a/templates/admin/torrentlist.html +++ b/templates/admin/torrentlist.html @@ -2,7 +2,7 @@ {{ range .Torrents}} - + {{end}}
{{ .Name }}Delete
{{ .Name }}Delete
{{end}}