Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Merge pull request #263 from azhao12345/more-moderation

delete shit
Cette révision appartient à :
ewhal 2017-05-10 17:17:11 +10:00 révisé par GitHub
révision da32c89b01
7 fichiers modifiés avec 27 ajouts et 9 suppressions

Voir le fichier

@ -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"`

Voir le fichier

@ -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"`

Voir le fichier

@ -40,8 +40,9 @@ func IndexModPanel(w http.ResponseWriter, r *http.Request) {
languages.SetTranslationFromRequest(panelIndex, r, "en-us")
htv := PanelIndexVbs{torrents, users, comments}
_ = panelIndex.ExecuteTemplate(w, "admin_index.html", htv)
} else {
http.Error(w, "admins only", http.StatusForbidden)
}
}
func TorrentsListPanel(w http.ResponseWriter, r *http.Request) {
currentUser := GetUser(r)
@ -54,6 +55,9 @@ func TorrentsListPanel(w http.ResponseWriter, r *http.Request) {
htv := PanelTorrentListVbs{torrents}
err := panelTorrentList.ExecuteTemplate(w, "admin_index.html", htv)
fmt.Println(err)
} else {
http.Error(w, "admins only", http.StatusForbidden)
}
}
func UsersListPanel(w http.ResponseWriter, r *http.Request) {
@ -67,6 +71,8 @@ func UsersListPanel(w http.ResponseWriter, r *http.Request) {
htv := PanelUserListVbs{users}
err := panelUserList.ExecuteTemplate(w, "admin_index.html", htv)
fmt.Println(err)
} else {
http.Error(w, "admins only", http.StatusForbidden)
}
}
func CommentsListPanel(w http.ResponseWriter, r *http.Request) {
@ -80,6 +86,8 @@ func CommentsListPanel(w http.ResponseWriter, r *http.Request) {
htv := PanelCommentListVbs{comments}
err := panelCommentList.ExecuteTemplate(w, "admin_index.html", htv)
fmt.Println(err)
} else {
http.Error(w, "admins only", http.StatusForbidden)
}
}
@ -92,6 +100,8 @@ func TorrentEditModPanel(w http.ResponseWriter, r *http.Request) {
htv := PanelTorrentEdVbs{torrent}
err := panelTorrentEd.ExecuteTemplate(w, "admin_index.html", htv)
fmt.Println(err)
} else {
http.Error(w, "admins only", http.StatusForbidden)
}
}
@ -120,6 +130,8 @@ func TorrentPostEditModPanel(w http.ResponseWriter, r *http.Request) {
languages.SetTranslationFromRequest(panelTorrentEd, r, "en-us")
htv := PanelTorrentEdVbs{torrent}
_ = panelTorrentEd.ExecuteTemplate(w, "admin_index.html", htv)
} else {
http.Error(w, "admins only", http.StatusForbidden)
}
}
@ -130,8 +142,10 @@ 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)
}
}
func TorrentDeleteModPanel(w http.ResponseWriter, r *http.Request) {
@ -140,7 +154,9 @@ 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)
}
}

Voir le fichier

@ -85,12 +85,11 @@ func init() {
Router.Handle("/mod/torrents", gzipTorrentsListPanel).Name("mod_tlist")
Router.Handle("/mod/users", gzipUsersListPanel).Name("mod_ulist")
Router.Handle("/mod/comments", gzipCommentsListPanel).Name("mod_clist")
Router.Handle("/mod/comments", gzipCommentsListPanel).Name("mod_cedit")
Router.Handle("/mod/comments", gzipCommentsListPanel).Name("mod_cdelete")
Router.Handle("/mod/comments", 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/delete", gzipCommentDeleteModPanel).Name("mod_tdelete")
Router.Handle("/mod/comment/delete", gzipTorrentDeleteModPanel).Name("mod_cdelete")
Router.Handle("/mod/torrent/delete", gzipTorrentDeleteModPanel).Name("mod_tdelete")
Router.Handle("/mod/comment/delete", gzipCommentDeleteModPanel).Name("mod_cdelete")
Router.PathPrefix("/captcha").Methods("GET").HandlerFunc(captcha.ServeFiles)

Voir le fichier

@ -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")

Voir le fichier

@ -2,7 +2,7 @@
<table>
{{ 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}}
</table>
{{end}}

Voir le fichier

@ -2,7 +2,7 @@
<table>
{{ 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}}
</table>
{{end}}