Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Revert "Mod Page (WIP)"

This reverts commit 55590cf7b3.
Cette révision appartient à :
akuma06 2017-05-10 04:03:09 +02:00
Parent 55590cf7b3
révision 233c859723
4 fichiers modifiés avec 0 ajouts et 96 suppressions

Voir le fichier

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

Voir le fichier

@ -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
}

Voir le fichier

@ -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
}

Voir le fichier

@ -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
}