delete shit
Cette révision appartient à :
Parent
7bffd59e85
révision
8d9605def3
6 fichiers modifiés avec 7 ajouts et 4 suppressions
|
@ -11,6 +11,7 @@ type Comment struct {
|
||||||
Content string `gorm:"column:content"`
|
Content string `gorm:"column:content"`
|
||||||
CreatedAt time.Time `gorm:"column:created_at"`
|
CreatedAt time.Time `gorm:"column:created_at"`
|
||||||
UpdatedAt time.Time `gorm:"column:updated_at"`
|
UpdatedAt time.Time `gorm:"column:updated_at"`
|
||||||
|
DeletedAt *time.Time
|
||||||
|
|
||||||
Torrent *Torrent `gorm:"ForeignKey:torrent_id"`
|
Torrent *Torrent `gorm:"ForeignKey:torrent_id"`
|
||||||
User *User `gorm:"ForeignKey:user_id"`
|
User *User `gorm:"ForeignKey:user_id"`
|
||||||
|
|
|
@ -34,6 +34,7 @@ type Torrent struct {
|
||||||
Filesize int64 `gorm:"column:filesize"`
|
Filesize int64 `gorm:"column:filesize"`
|
||||||
Description string `gorm:"column:description"`
|
Description string `gorm:"column:description"`
|
||||||
WebsiteLink string `gorm:"column:website_link"`
|
WebsiteLink string `gorm:"column:website_link"`
|
||||||
|
DeletedAt *time.Time
|
||||||
|
|
||||||
Uploader *User `gorm:"ForeignKey:UploaderId"`
|
Uploader *User `gorm:"ForeignKey:UploaderId"`
|
||||||
OldComments []OldComment `gorm:"ForeignKey:torrent_id"`
|
OldComments []OldComment `gorm:"ForeignKey:torrent_id"`
|
||||||
|
|
|
@ -142,7 +142,7 @@ func CommentDeleteModPanel(w http.ResponseWriter, r *http.Request) {
|
||||||
if userPermission.HasAdmin(currentUser) {
|
if userPermission.HasAdmin(currentUser) {
|
||||||
_ = form.NewErrors()
|
_ = form.NewErrors()
|
||||||
_, _ = userService.DeleteComment(id)
|
_, _ = 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)
|
http.Redirect(w, r, url.String()+"?deleted", http.StatusSeeOther)
|
||||||
} else {
|
} else {
|
||||||
http.Error(w, "admins only", http.StatusForbidden)
|
http.Error(w, "admins only", http.StatusForbidden)
|
||||||
|
@ -154,7 +154,7 @@ 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)
|
||||||
url, _ := Router.Get("mod_torrent_list").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 {
|
||||||
http.Error(w, "admins only", http.StatusForbidden)
|
http.Error(w, "admins only", http.StatusForbidden)
|
||||||
|
|
|
@ -97,6 +97,7 @@ func getTorrentsOrderBy(parameters *WhereParams, orderBy string, limit int, offs
|
||||||
torrents []model.Torrent, count int, err error,
|
torrents []model.Torrent, count int, err error,
|
||||||
) {
|
) {
|
||||||
var conditionArray []string
|
var conditionArray []string
|
||||||
|
conditionArray = append(conditionArray, "deleted_at IS NULL")
|
||||||
if strings.HasPrefix(orderBy, "filesize") {
|
if strings.HasPrefix(orderBy, "filesize") {
|
||||||
// torrents w/ NULL filesize fuck up the sorting on Postgres
|
// torrents w/ NULL filesize fuck up the sorting on Postgres
|
||||||
conditionArray = append(conditionArray, "filesize IS NOT NULL")
|
conditionArray = append(conditionArray, "filesize IS NOT NULL")
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<table>
|
<table>
|
||||||
{{ range .Comments}}
|
{{ range .Comments}}
|
||||||
|
|
||||||
<tr><td><a href="{{ genRoute "mod_cedit" }}?id={{.ID}}">{{ .Content }}</a></td><td><a href="{{ genRoute "mod_cdelete" }}?id{{ .ID }}">Delete</a></td></tr>
|
<tr><td><a href="{{ genRoute "mod_cedit" }}?id={{.ID}}">{{ .Content }}</a></td><td><a href="{{ genRoute "mod_cdelete" }}?id={{ .ID }}">Delete</a></td></tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
</table>
|
</table>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<table>
|
<table>
|
||||||
{{ range .Torrents}}
|
{{ range .Torrents}}
|
||||||
|
|
||||||
<tr><td><a href="{{ genRoute "mod_tedit" }}?id={{.ID}}">{{ .Name }}</a></td><td><a href="{{ genRoute "mod_tdelete" }}?id{{ .ID }}">Delete</a></td></tr>
|
<tr><td><a href="{{ genRoute "mod_tedit" }}?id={{.ID}}">{{ .Name }}</a></td><td><a href="{{ genRoute "mod_tdelete" }}?id={{ .ID }}">Delete</a></td></tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
</table>
|
</table>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Référencer dans un nouveau ticket