diff --git a/router/modpanel.go b/router/modpanel.go deleted file mode 100644 index fbc0e951..00000000 --- a/router/modpanel.go +++ /dev/null @@ -1,57 +0,0 @@ -// hurry mod panel to get it faaaaaaaaaaaast - -package router - -import ( - "fmt" - "net/http" - "strconv" - "html/template" - - "github.com/ewhal/nyaa/model" - "github.com/ewhal/nyaa/service/user" - "github.com/ewhal/nyaa/service/user/permission" - // "github.com/ewhal/nyaa/util/languages" - // "github.com/ewhal/nyaa/util/modelHelper" - "github.com/gorilla/mux" -) - -var panelCommentList *template.Template -func init() { - panelCommentList = template.Must(template.New("commentlist").Funcs(FuncMap).ParseFiles(filepath.Join(TemplateDir, "admin_index.html"), filepath.Join(TemplateDir, "admin/commentlist.html"))) -} - -func IndexModPanel(w http.ResponseWriter, r *http.Request) {} -func TorrentsListPanel(w http.ResponseWriter, r *http.Request) {} -func UsersListPanel(w http.ResponseWriter, r *http.Request) {} -func CommentsListPanel(w http.ResponseWriter, r *http.Request) { - page,_ := strconv.Atoi(r.URL.Query().Get("p")) - offset := 100 - - comments := commentService.GetAllTorrents(page*offset, offset) - languages.SetTranslationFromRequest(panelCommentList, r, "en-us") - htv := PanelCommentListVbs{comments} - err := panelCommentList.ExecuteTemplate(w, "index.html", htv) - -} -func TorrentEditModPanel(w http.ResponseWriter, r *http.Request) { - // Todo -} -func CommentDeleteModPanel(w http.ResponseWriter, r *http.Request) { - currentUser := GetUser(r) - if (HasAdmin(currentUser)) { - err := form.NewErrors() - _, _ := userService.DeleteComment(id) - url, _ := Router.Get("mod_comment_list") - http.Redirect(w, r, url.String()+"?deleted", http.StatusSeeOther) - } -} -func TorrentDeleteModPanel(w http.ResponseWriter, r *http.Request) { - currentUser := GetUser(r) - if (HasAdmin(currentUser)) { - err := form.NewErrors() - _, _ := torrentService.DeleteTorrent(id) - url, _ := Router.Get("mod_torrent_list") - http.Redirect(w, r, url.String()+"?deleted", http.StatusSeeOther) - } -} \ No newline at end of file diff --git a/service/comment/comment.go b/service/comment/comment.go deleted file mode 100644 index 336b7cb2..00000000 --- a/service/comment/comment.go +++ /dev/null @@ -1,17 +0,0 @@ -package commentService - -import ( - "net/http" - - "github.com/ewhal/nyaa/db" - "github.com/ewhal/nyaa/model" - "github.com/ewhal/nyaa/service/user/permission" - "github.com/ewhal/nyaa/util/modelHelper" - -) - -func GetAllComments(limit int, offset int) { - var comments []model.Comment - db.ORM.Limit(limit).Offset(offset).Preload("Uploader").Find(&comments) - return comments -} diff --git a/service/torrent/torrent.go b/service/torrent/torrent.go index 6a83451e..02ac59dc 100644 --- a/service/torrent/torrent.go +++ b/service/torrent/torrent.go @@ -176,14 +176,3 @@ func CreateWhereParams(conditions string, params ...string) WhereParams { } return whereParams } - -func DeleteTorrent(id string) { - var torrent model.Torrents - if db.ORM.First(&torrent, id).RecordNotFound() { - return http.StatusNotFound, errors.New("Torrent is not found.") - } - if db.ORM.Delete(&torrent).Error != nil { - return http.StatusInternalServerError, errors.New("Torrent is not deleted.") - } - return http.StatusOK, nil -} \ No newline at end of file diff --git a/service/user/user.go b/service/user/user.go index 7c6b8399..b2579339 100644 --- a/service/user/user.go +++ b/service/user/user.go @@ -305,15 +305,4 @@ func RemoveFollow(user *model.User, follower *model.User) { var userFollows = model.UserFollows{UserID: user.Id, FollowerID: follower.Id} db.ORM.Delete(&userFollows) } -} - -func DeleteComment(id string) { - var comment model.Comment - if db.ORM.First(&comment, id).RecordNotFound() { - return http.StatusNotFound, errors.New("Comment is not found.") - } - if db.ORM.Delete(&comment).Error != nil { - return http.StatusInternalServerError, errors.New("Comment is not deleted.") - } - return http.StatusOK, nil } \ No newline at end of file