Modpanel stuff (#401)
* Fix table on modpanel index * Fix actions on torrent report list page * Fix error reporting on modpanel templates * Convenience functions for modpanel Link to view page primarily and to edit page as a seperate link * Missing confirm before torrent deletion * Add edit button directly onto view page
Cette révision appartient à :
Parent
d34f2f3959
révision
00bb382cdb
6 fichiers modifiés avec 36 ajouts et 14 suppressions
|
@ -33,7 +33,8 @@ func IndexModPanel(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
languages.SetTranslationFromRequest(panelIndex, r, "en-us")
|
||||
htv := PanelIndexVbs{torrents, model.TorrentReportsToJSON(torrentReports), users, comments, NewSearchForm(), currentUser, r.URL}
|
||||
_ = panelIndex.ExecuteTemplate(w, "admin_index.html", htv)
|
||||
err := panelIndex.ExecuteTemplate(w, "admin_index.html", htv)
|
||||
log.CheckError(err)
|
||||
} else {
|
||||
http.Error(w, "admins only", http.StatusForbidden)
|
||||
}
|
||||
|
@ -217,7 +218,8 @@ func TorrentPostEditModPanel(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
languages.SetTranslationFromRequest(panelTorrentEd, r, "en-us")
|
||||
htv := PanelTorrentEdVbs{uploadForm, NewSearchForm(), currentUser, err, infos, r.URL}
|
||||
_ = panelTorrentEd.ExecuteTemplate(w, "admin_index.html", htv)
|
||||
err_ := panelTorrentEd.ExecuteTemplate(w, "admin_index.html", htv)
|
||||
log.CheckError(err_)
|
||||
}
|
||||
|
||||
func CommentDeleteModPanel(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
@ -26,6 +26,16 @@ var FuncMap = template.FuncMap{
|
|||
}
|
||||
return "error"
|
||||
},
|
||||
"genViewTorrentRoute": func(torrent_id uint) string {
|
||||
// Helper for when you have an uint while genRoute("view_torrent", ...) takes a string
|
||||
// FIXME better solution?
|
||||
s := strconv.FormatUint(uint64(torrent_id), 10)
|
||||
url, err := Router.Get("view_torrent").URL("id", s)
|
||||
if err == nil {
|
||||
return url.String()
|
||||
}
|
||||
return "error"
|
||||
},
|
||||
"genNav": func(nav Navigation, currentUrl *url.URL, pagesSelectable int) template.HTML {
|
||||
var ret = ""
|
||||
if (nav.TotalItem > 0) {
|
||||
|
|
|
@ -7,9 +7,12 @@
|
|||
<th class="col-xs-1">Uploader</th>
|
||||
<th class="col-xs-1">Action</th>
|
||||
</tr>
|
||||
{{ range .Torrents}}
|
||||
<tr><td><a href="{{ genRoute "mod_tedit" }}?id={{.ID}}">{{ .Name }}</a></td><td><a href="{{ genRoute "mod_tlist" }}?userID={{.UploaderID}}">{{ .UploaderID }}</a></td>
|
||||
<td><a href="{{ genRoute "mod_tdelete" }}?id={{ .ID }}" class="btn btn-danger btn-lg" onclick="if (!confirm('Are you sure?')) return false;"><i class="glyphicon glyphicon-trash"></i>{{ T "delete" }}</a></td></tr>
|
||||
{{range .Torrents}}
|
||||
<tr>
|
||||
<td><a href="{{ genViewTorrentRoute .ID }}">{{ .Name }}</a> (<a href="{{ genRoute "mod_tedit" }}?id={{.ID}}">Edit</a>)</td>
|
||||
<td><a href="{{ genRoute "mod_tlist" }}?userID={{.UploaderID}}">{{ .UploaderID }}</a></td>
|
||||
<td><a href="{{ genRoute "mod_tdelete" }}?id={{ .ID }}" class="btn btn-danger btn-lg" onclick="if (!confirm('Are you sure?')) return false;"><i class="glyphicon glyphicon-trash"></i>{{ T "delete" }}</a></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
<nav class="torrentNav" aria-label="Page navigation">
|
||||
|
@ -21,7 +24,6 @@
|
|||
|
||||
<h3 id="torrents">Last Torrents Report</h3>
|
||||
<table class="table">
|
||||
{{ range .TorrentReports}}
|
||||
<tr>
|
||||
<th class="col-xs-9">Torrent Name</th>
|
||||
<th class="col-xs-1">User</th>
|
||||
|
@ -29,8 +31,13 @@
|
|||
<th class="col-xs-1">Action</th>
|
||||
</tr>
|
||||
|
||||
<tr><td><a href="{{ genRoute "mod_tedit" }}?id={{.Torrent.ID}}">{{ .Torrent.Name }}</a></td><td>{{.User.Username}}</td><td>{{.Description}}</td>
|
||||
<td><a href="{{ genRoute "mod_trdelete" }}?id={{ .ID }}" class="btn btn-danger btn-lg" onclick="if (!confirm('Are you sure?')) return false;"><i class="glyphicon glyphicon-trash"></i>{{ T "delete" }}</a></td></tr>
|
||||
{{range .TorrentReports}}
|
||||
<tr>
|
||||
<td><a href="{{ genRoute "view_torrent" "id" .Torrent.ID }}">{{ .Torrent.Name }}</a> (<a href="{{ genRoute "mod_tedit" }}?id={{.Torrent.ID}}">Edit</a>)</td>
|
||||
<td>{{.User.Username}}</td>
|
||||
<td>{{.Description}}</td>
|
||||
<td><a href="{{ genRoute "mod_trdelete" }}?id={{ .ID }}" class="btn btn-danger btn-lg" onclick="if (!confirm('Are you sure?')) return false;"><i class="glyphicon glyphicon-trash"></i>{{ T "delete" }}</a></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
<nav class="torrentNav" aria-label="Page navigation">
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
<th class="col-xs-1">Action</th>
|
||||
</tr>
|
||||
|
||||
{{ range .TorrentReports}}
|
||||
{{range .TorrentReports}}
|
||||
<tr>
|
||||
<td><a href="{{ genRoute "mod_tedit"}}?id={{.Torrent.ID}}">{{.Torrent.Name}}</a></td>
|
||||
<td><a href="{{ genRoute "view_torrent" "id" .Torrent.ID }}">{{ .Torrent.Name }}</a> (<a href="{{ genRoute "mod_tedit" }}?id={{.Torrent.ID}}">Edit</a>)</td>
|
||||
<td>{{.User.Username}}</td>
|
||||
<td>{{.Description}}</td>
|
||||
<td><a href="{{ genRoute "mod_tdelete" }}?id={{ .Torrent.ID }}">Delete</a>
|
||||
<td><a href="{{ genRoute "mod_tdelete" }}?id={{ .Torrent.ID }}" onclick="if (!confirm('Are you sure?')) return false;">Delete</a><br />
|
||||
<a href="{{ genRoute "mod_trdelete" }}?id={{ .ID }}">Delete Report</a></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
|
|
|
@ -10,9 +10,11 @@
|
|||
</tr>
|
||||
|
||||
{{ range .Torrents}}
|
||||
|
||||
<tr><td><a href="{{ genRoute "mod_tedit" }}?id={{.ID}}">{{ .Name }}</a></td><td><a href="{{ genRoute "mod_tlist" }}?userID={{.UploaderID}}">{{ .UploaderID }}</a></td>
|
||||
<td><a href="{{ genRoute "mod_tdelete" }}?id={{ .ID }}" class="btn btn-danger btn-lg" onclick="if (!confirm('Are you sure?')) return false;"><i class="glyphicon glyphicon-trash"></i>{{ T "delete" }}</a></td></tr>
|
||||
<tr>
|
||||
<td><a href="{{ genViewTorrentRoute .ID }}">{{ .Name }}</a> (<a href="{{ genRoute "mod_tedit" }}?id={{.ID}}">Edit</a>)</td>
|
||||
<td><a href="{{ genRoute "mod_tlist" }}?userID={{.UploaderID}}">{{ .UploaderID }}</a></td>
|
||||
<td><a href="{{ genRoute "mod_tdelete" }}?id={{ .ID }}" class="btn btn-danger btn-lg" onclick="if (!confirm('Are you sure?')) return false;"><i class="glyphicon glyphicon-trash"></i>{{ T "delete" }}</a></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
<nav class="torrentNav" aria-label="Page navigation">
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
{{ if HasAdmin $.User}}
|
||||
<a href="{{ genRoute "mod_tdelete" }}?id={{ .ID }}" class="btn btn-danger btn-lg" onclick="if (!confirm('Are you sure?')) return false;"><i class="glyphicon glyphicon-trash"></i></a>
|
||||
<a href="{{ genRoute "mod_tedit" }}?id={{ .ID }}" class="btn btn-warning btn-lg"><i class="glyphicon glyphicon-pencil"></i></a>
|
||||
{{end}}
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
|
|
Référencer dans un nouveau ticket