some pages not dispyaing corectly in mod page
Cette révision appartient à :
Parent
de7474baef
révision
fcd0fec9a5
3 fichiers modifiés avec 57 ajouts et 24 suppressions
|
@ -3,22 +3,24 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"html"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"fmt"
|
||||
|
||||
"github.com/ewhal/nyaa/service/comment"
|
||||
"github.com/ewhal/nyaa/service/moderation"
|
||||
"github.com/ewhal/nyaa/service/torrent"
|
||||
"github.com/ewhal/nyaa/service/torrent/form"
|
||||
"github.com/ewhal/nyaa/util/search"
|
||||
"github.com/ewhal/nyaa/service/user"
|
||||
form "github.com/ewhal/nyaa/service/user/form"
|
||||
"github.com/ewhal/nyaa/service/user/permission"
|
||||
"github.com/ewhal/nyaa/util/languages"
|
||||
"github.com/ewhal/nyaa/util/log"
|
||||
"github.com/ewhal/nyaa/util/modelHelper"
|
||||
"github.com/ewhal/nyaa/util/search"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
|
@ -59,10 +61,20 @@ func TorrentsListPanel(w http.ResponseWriter, r *http.Request) {
|
|||
currentUser := GetUser(r)
|
||||
if userPermission.HasAdmin(currentUser) {
|
||||
vars := mux.Vars(r)
|
||||
page, _ := strconv.Atoi(vars["page"])
|
||||
page := vars["page"]
|
||||
|
||||
var err error
|
||||
pagenum := 1
|
||||
if page != "" {
|
||||
pagenum, err = strconv.Atoi(html.EscapeString(page))
|
||||
if !log.CheckError(err) {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
offset := 100
|
||||
|
||||
searchParam, torrents, _, err := search.SearchByQuery(r, page)
|
||||
searchParam, torrents, _, err := search.SearchByQuery(r, pagenum)
|
||||
searchForm := SearchForm{
|
||||
SearchParam: searchParam,
|
||||
Category: searchParam.Category.String(),
|
||||
|
@ -70,7 +82,7 @@ func TorrentsListPanel(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
languages.SetTranslationFromRequest(panelTorrentList, r, "en-us")
|
||||
htv := PanelTorrentListVbs{torrents, searchForm, Navigation{int(searchParam.Max), offset, page, "mod_tlist_page"}, currentUser, r.URL}
|
||||
htv := PanelTorrentListVbs{torrents, searchForm, Navigation{int(searchParam.Max), offset, pagenum, "mod_tlist_page"}, currentUser, r.URL}
|
||||
err = panelTorrentList.ExecuteTemplate(w, "admin_index.html", htv)
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
|
@ -82,13 +94,23 @@ func UsersListPanel(w http.ResponseWriter, r *http.Request) {
|
|||
currentUser := GetUser(r)
|
||||
if userPermission.HasAdmin(currentUser) {
|
||||
vars := mux.Vars(r)
|
||||
page, _ := strconv.Atoi(vars["page"])
|
||||
page := vars["page"]
|
||||
|
||||
var err error
|
||||
pagenum := 1
|
||||
if page != "" {
|
||||
pagenum, err = strconv.Atoi(html.EscapeString(page))
|
||||
if !log.CheckError(err) {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
offset := 100
|
||||
|
||||
users, nbUsers := userService.RetrieveUsersForAdmin(offset, page*offset)
|
||||
users, nbUsers := userService.RetrieveUsersForAdmin(offset, (pagenum-1)*offset)
|
||||
languages.SetTranslationFromRequest(panelUserList, r, "en-us")
|
||||
htv := PanelUserListVbs{users, NewSearchForm(), Navigation{nbUsers, offset, page, "mod_ulist_page"}, currentUser, r.URL}
|
||||
err := panelUserList.ExecuteTemplate(w, "admin_index.html", htv)
|
||||
htv := PanelUserListVbs{users, NewSearchForm(), Navigation{nbUsers, offset, pagenum, "mod_ulist_page"}, currentUser, r.URL}
|
||||
err = panelUserList.ExecuteTemplate(w, "admin_index.html", htv)
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
http.Error(w, "admins only", http.StatusForbidden)
|
||||
|
@ -98,19 +120,30 @@ func CommentsListPanel(w http.ResponseWriter, r *http.Request) {
|
|||
currentUser := GetUser(r)
|
||||
if userPermission.HasAdmin(currentUser) {
|
||||
vars := mux.Vars(r)
|
||||
page, _ := strconv.Atoi(vars["page"])
|
||||
page := vars["page"]
|
||||
|
||||
var err error
|
||||
pagenum := 1
|
||||
if page != "" {
|
||||
pagenum, err = strconv.Atoi(html.EscapeString(page))
|
||||
if !log.CheckError(err) {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
offset := 100
|
||||
userid := r.URL.Query().Get("userid")
|
||||
var conditions string
|
||||
var values []interface{}
|
||||
if (userid != "") {
|
||||
if userid != "" {
|
||||
conditions = "user_id = ?"
|
||||
values = append(values, userid)
|
||||
}
|
||||
comments, nbComments := commentService.GetAllComments(offset, page * offset, conditions, values...)
|
||||
|
||||
comments, nbComments := commentService.GetAllComments(offset, (pagenum-1)*offset, conditions, values...)
|
||||
languages.SetTranslationFromRequest(panelCommentList, r, "en-us")
|
||||
htv := PanelCommentListVbs{comments, NewSearchForm(), Navigation{nbComments, offset, page, "mod_clist_page"}, currentUser, r.URL}
|
||||
err := panelCommentList.ExecuteTemplate(w, "admin_index.html", htv)
|
||||
htv := PanelCommentListVbs{comments, NewSearchForm(), Navigation{nbComments, offset, pagenum, "mod_clist_page"}, currentUser, r.URL}
|
||||
err = panelCommentList.ExecuteTemplate(w, "admin_index.html", htv)
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
http.Error(w, "admins only", http.StatusForbidden)
|
||||
|
|
|
@ -107,7 +107,7 @@ func init() {
|
|||
// TODO Allow only moderators to access /moderation/*
|
||||
//Router.Handle("/moderation/report/delete", gzipTorrentReportDeleteHandler).Name("torrent_report_delete").Methods("POST")
|
||||
//Router.Handle("/moderation/torrent/delete", gzipTorrentDeleteHandler).Name("torrent_delete").Methods("POST")
|
||||
Router.Handle("/mod/reports", gzipGetTorrentReportHandler).Name("torrent_report").Methods("GET")
|
||||
Router.Handle("/mod/reports", gzipGetTorrentReportHandler).Name("mod_trlist").Methods("GET")
|
||||
Router.Handle("/mod/reports/{page}", gzipGetTorrentReportHandler).Name("mod_trlist").Methods("GET")
|
||||
|
||||
Router.NotFoundHandler = http.HandlerFunc(NotFoundHandler)
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
</table>
|
||||
<nav class="torrentNav" aria-label="Page navigation">
|
||||
<ul class="pagination">
|
||||
<li><a href="{{ genRoute "mod_ulist" }}">More</a></li>
|
||||
<li><a href="{{ genRoute "mod_clist" }}">More</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
{{end}}
|
Référencer dans un nouveau ticket